I have a ListView whose ListItems(RelativeLayout) have
A textView and two ImageButtons inside a LinearLayout.
Here is the xml of my ListItem;
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:descendantFocusability="blocksDescendants"
>
<TextView
android:id="#+id/list_item_quote"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingBottom="15dp"
android:paddingTop="15dp"
style="#style/quote_text"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/lytShareLike"
android:layout_gravity="center"
android:gravity="center"
android:visibility="gone"
android:layout_margin="1dp"
android:layout_alignLeft="#id/list_item_quote"
android:layout_alignTop="#id/list_item_quote"
android:layout_alignRight="#id/list_item_quote"
android:layout_alignBottom="#id/list_item_quote">
<ImageButton
android:layout_width="30dp"
android:layout_height="30dp"
android:scaleType="centerInside"
android:id="#+id/btnShare"
android:background="#null"
android:onClick="quoteShareClick"
android:src="#drawable/share"
android:layout_marginRight="10dp"
/>
<ImageButton
android:layout_width="30dp"
android:layout_height="30dp"
android:scaleType="centerInside"
android:id="#+id/btnLike"
android:background="#null"
android:src="#drawable/heartnot"
android:onClick="quoteLikeClick"
/>
</LinearLayout>
</RelativeLayout>
I have ItemClickListener which sets the LinearLayout visible when the ListItem is clicked. There is no problem until here.
What I want to do is, after clicking a ListItem, if the user clicks another ListItem, the other unclicked Listitems' LinearLayouts should be GONE again.
Here is my onClickListener;
listQuotes.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
LinearLayout lytShareLike = (LinearLayout) view.findViewById(R.id.lytShareLike);
for (int i = 0; i < listQuotes.getAdapter().getCount(); i++) {
if (position != i && i != 0) {
LinearLayout lnrTemp = (LinearLayout) listQuotes.getAdapter().getView(i, null, null).findViewById(R.id.lytShareLike);
lnrTemp.setVisibility(View.GONE);
}
}
}
});
The for iteration iterates the items and LinearLayouts as expected but the LinearLayouts are still VISIBLE
What am I missing?
you can control it by using below code:
//...
int index = -1;
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
index = position;
mAdaper..notifyDataSetChanged();
}
//...
in the adapter:
#Override
public View getView(int position, View convertView, ViewGroup parent) {
//...
Holder holder;
if(convertView == null) {
convertView = ....;
holder = new Holder(convertView);
convertView.setTag(holder);
}
holder = (Holder) convertView.getTag();
if(index == position){
holder.linearLayout.setVisibility(View.VISIBLE);
} else {
holder.linearLayout.setVisibility(View.GONE);
}
//...
return convertView;
}
Related
I am making an app in which there are posts with comments and description. There are three buttons on each post. 1 description 2 comments and third is like button. I set a button click listener in getview method of custom adapter. When i click on description button the description of that post should be displayed under the button. But when i clicked the description button, the description of some other listview items also displayed. I just want to show the description of that post whose description button is clicked. Here is my code:
getview code:
public View getView(int position, View convertView, ViewGroup parent) {
a = getItem(position);
View view = convertView;
try
{
if (convertView == null) {
v = new ViewHolder();
convertView = LayoutInflater.from(getContext()).inflate(R.layout.custom_list_item, parent, false);
v.imgView = (ImageView) convertView.findViewById(R.id.iv_list_image);
v.desc = (Button) convertView.findViewById(R.id.btn_desc);
v.des = (TextView) convertView.findViewById(R.id.tv_list_desc);
v.ll = (LinearLayout) convertView.findViewById(R.id.ll_desc);
convertView.setTag(v);
}
else {
v = (ViewHolder) convertView.getTag();
}
v.desc.setTag(position);
//Picasso.with(getContext()).load(a.getFile()).fit().into(v.imgView);
Glide.with(context).load(a.getFile()).centerCrop().placeholder(R.drawable.dualring).into(v.imgView);
v.desc.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v1) {
Toast.makeText(getContext(), ""+v.desc.getTag(), Toast.LENGTH_SHORT).show();
v.des.setText(""+a.getDescription());
v.ll.setVisibility(View.VISIBLE);
}
});
return convertView;
}catch (Exception e)
{
return null;
}
}
XML code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp"
android:paddingBottom="35dp">
<ImageView
android:id="#+id/iv_list_image"
android:layout_width="match_parent"
android:layout_height="300dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight="6">
<Button
android:id="#+id/btn_desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="Description"
/>
<Button
android:id="#+id/btn_comment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="Comments"
/>
<Button
android:id="#+id/btn_likes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="Likes"
/>
</LinearLayout>
<LinearLayout
android:id="#+id/ll_desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp"
android:background="#ffffff"
android:visibility="invisible"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Description:"
android:textStyle="bold"/>
<TextView
android:id="#+id/tv_list_desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Default Desc"
android:textColor="#333"
/>
</LinearLayout>
</LinearLayout>
That's when you use an int flag for the list item's position as a conditional statement before updating the ListView's items.
So in your case, the Adapter class would look something like this:
...
private int mPosition = -1; // Int flag that doesn't take effect UNTIL it has been set
...
#Override
public View getView(final int position, View convertView, ViewGroup parent) {
a = getItem(position);
View view = convertView;
try {
if (convertView == null) {
v = new ViewHolder();
convertView = LayoutInflater.from(getContext()).inflate(R.layout.custom_list_item, parent, false);
v.imgView = (ImageView) convertView.findViewById(R.id.iv_list_image);
v.desc = (Button) convertView.findViewById(R.id.btn_desc);
v.des = (TextView) convertView.findViewById(R.id.tv_list_desc);
v.ll = (LinearLayout) convertView.findViewById(R.id.ll_desc);
convertView.setTag(v);
} else {
v = (ViewHolder) convertView.getTag();
}
v.desc.setTag(position);
//Picasso.with(getContext()).load(a.getFile()).fit().into(v.imgView);
Glide.with(context).load(a.getFile()).centerCrop().placeholder(R.drawable.dualring)
.into(v.imgView);
// Runs the following functionality if the positions match. Otherwise, hides the layout.
if (mPosition == position) {
Toast.makeText(getContext(), ""+v.desc.getTag(), Toast.LENGTH_SHORT).show();
v.des.setText(""+a.getDescription());
v.ll.setVisibility(View.VISIBLE);
} else {
v.ll.setVisibility(View.INVISIBLE);
}
v.desc.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v1) {
mPosition = position; // Sets the flag to the position that was clicked
notifyDataSetChanged(); // Updates the data instantly
}
});
return convertView;
} catch (Exception e) {
return null;
}
}
Let me know if that works.
The best way is to implement the on click listener in adapter and set the tag on button. After that in onclick method perform the desired task through getting tag id of button, this will definitely work.
I am trying to add a grey background color to spinner and its itemrow,want to change text color to blue and want to place image in right of spinner .Currently i am getting white color in note device and black color in tab device.
i am very new to android please help me.
main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/moviesSpinner"
android:prompt="#string/movie_prompt" />
<ImageView
android:src="#android:drawable/Icon"
android:layout_width="30dp"
android:layout_height="30dp"
android:id="#+id/imageView1" />
</LinearLayout>
itemrow.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#ffffff"
android:padding="3dip">
<TextView
android:padding="3dip"
android:layout_marginTop="2dip"
android:textColor="#C11B17"
android:textStyle="bold"
android:id="#+id/company"
android:layout_marginLeft="5dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
mainActivity.cs
var moviesSpinner1 = FindViewById<Spinner>(Resource.Id.moviesSpinner);
moviesSpinner1.Adapter = new MoviesAdapter(this, MoviesRepository.Movies);
public class SpinnerAdapter extends ArrayAdapter<SpinnerItem> {
private Context mContext;
private ArrayList<SpinnerItem> listState;
public SpinnerAdapter(Context context, int resource,
ArrayList<SpinnerItem> objects) {
super(context, resource, objects);
this.mContext = context;
this.listState = objects;
}
#Override
public View getDropDownView(int position, View convertView, ViewGroup parent) {
return getCustomView(position, convertView, parent, true);
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
return getCustomView(position, convertView, parent, false);
}
#SuppressLint("InflateParams")
public View getCustomView(int position, View convertView, ViewGroup parent, boolean isDropDown) {
final ViewHolder holder;
if (convertView == null) {
LayoutInflater layoutInflator = LayoutInflater.from(mContext);
convertView = layoutInflator.inflate(R.layout.spinner_item_layout,
null);
holder = new ViewHolder();
holder.mTextView = (TextView) convertView.findViewById(R.id.text);
holder.mCheckedImage = (ImageView) convertView
.findViewById(R.id.checkbox);
holder.mBgLayout= (RelativeLayout) convertView
.findViewById(R.id.bg);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.mTextView.setText(listState.get(position).getTitle());
if (isDropDown) {
if (listState.get(position).isSelected()) {
holder.mCheckedImage.setVisibility(View.VISIBLE);
holder.mBgLayout.setBackgroundColor(android.Color.BLUE); // not sure if the syntax is correct. you need to check this line
} else {
holder.mCheckedImage.setVisibility(View.INVISIBLE);
holder.mBgLayout.setBackgroundColor(android.Color.YELLOW); // not sure if the syntax is correct. you need to check this line
}
}
return convertView;
}
private class ViewHolder {
private TextView mTextView;
private ImageView mCheckedImage;
private RelativeLayout mBgLayout;
}
public void setSpinnerAdapter(ArrayList<SpinnerItem> spinnerItems) {
this.listState = spinnerItems;
notifyDataSetChanged();
}
}
private void setBottelCountData() {
final String[] select_qualification = { "", "1", "2",
"3" };
bottelCountList = new ArrayList<>();
for (int i = 0; i < select_qualification.length; i++) {
SpinnerItem spinnerItem = new SpinnerItem();
spinnerItem.setTitle(select_qualification[i]);
if (i == 2) {
spinnerItem.setSelected(false);
} else {
spinnerItem.setSelected(false);
}
bottelCountList.add(spinnerItem);
}
bottelCountAdapter = new SpinnerAdapter(getActivity(), 0,
bottelCountList);
bottelCountAdapter.setDropDownViewResource(R.layout.spinner_item_layout);
bottel_Count_Spinner.setAdapter(bottelCountAdapter);
bottel_Count_Spinner.setSelection(3);
}
bottel_Count_Spinner
.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent,
View view, int position, long id) {
if (position == 0) {
for (int count = 0; count < bottelCountList.size(); count++) {
bottelCountList.get(count).setSelected(false);
}
noOfBottel = 0;
return;
}
bottelCountList.get(position).setSelected(true);
for (int count = 0; count < bottelCountList.size(); count++) {
if (position != count) {
bottelCountList.get(count).setSelected(false);
}
}
bottel_Count_Spinner.setPrompt("Hello");
bottelCountAdapter.setSpinnerAdapter(bottelCountList);
noOfBottel = Integer.parseInt(bottelCountList.get(
position).getTitle());
}
public void onNothingSelected(AdapterView<?> parent) {
}
});
use this xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:id="#+id/bg"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/checkbox"
android:layout_centerVertical="true"
android:padding="10dp"/>
<ImageView
android:id="#+id/checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:padding="10dp"
android:src="#android:drawable/checkbox_on_background"
android:contentDescription="#string/app_name"
android:layout_marginLeft="10dp"
android:layout_alignParentStart="true" />
</RelativeLayout>
i hope that will help you. if you find any error let know
I have an list View with two Item in each row is two TextView.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:id="#+id/content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:orientation="vertical">
<TextView
android:id="#+id/txtInfo"
android:layout_width="wrap_content"
android:layout_height="30sp"
android:layout_gravity="right"
android:textSize="12sp"
android:visibility="gone"
android:textColor="#android:color/darker_gray" />
<LinearLayout
android:id="#+id/contentWithBackground"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:background="#drawable/my_textview_border"
android:paddingLeft="10dp"
android:paddingBottom="10dp"
android:orientation="vertical">
<TextView
android:id="#+id/txtMessage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#android:color/black"
android:padding="10dp"
android:maxWidth="240dp" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
Now I want to show the hidden TextView just on the row I click with onItemClick(AdapterView<?> parent, View view, int position, long id) method but how can I set an detail id for each TextView. I mean the TextView just VISIBLE in the row I touch, not all of that TextView in other row.
Extend your class Activity by implements OnItemClickListener
use yourList.setOnItemClickListener(this); in onCreate()
Override onItemClick using this way:
s
#Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
TextView tv = (TextView) view.findViewById(R.id.txtMessage);
tv.setVisibility(View.VISIBLE);
}
do not forget to override your getView() arrayAdapter method:
a
public View getView(int position, View convertView, ViewGroup list) {
View element;
if (convertView == null) {
element = View.inflate(ctx, R.layout.yourlayout, null);
} else {
element = convertView;
}
///setup your listview element
return element;
}
EDIT
to change all data for textview I will work in such way:
yourarrayadater.setupmydata();
yourarrayadater.notifyDataSetChanged()
after that arrayadapter will redraw using getView.
So, use again
public View getView(int position, View convertView, ViewGroup list) {
View element;
if (convertView == null) {
element = View.inflate(ctx, R.layout.yourlayout, null);
} else {
element = convertView;
}
TextView tv = (TextView) element.findViewById(R.id.txtMessage);
///SETUP YOUR tv for each row
return element;
}
When I click the button in the ListView, I see the toast once. Then further clicks don't show anything when I click away from the button and in an empty space in the ListView, all the button click events that were not responding earlier appear at once (many toasts pop up one after another). Any idea how to fix this?
class Adapter extends ArrayAdapter
{
HashMap<Integer, View> rowViews = new HashMap<Integer, View>();
public Adapter(Context context) {
super(context, R.layout.manage_member_row, members);
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
final View rowView;
if(rowViews.containsKey(position)) {
rowView = rowViews.get(position);
} else {
rowView = inflater.inflate(R.layout.manage_member_row, parent, false);
((TextView) rowView.findViewById(R.id.manage_member_row_name)).setText(members.get(position).name);
rowViews.put(position, rowView);
}
((Button) rowView.findViewById(R.id.manage_member_row_delete)).setOnClickListener(new View.OnClickListener(){
public void onClick(View v) {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(), "btnclick", Toast.LENGTH_SHORT).show();
}
});
Log.i("CRC", "called");
return rowView;
}
//manage_member_row.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_alignParentBottom="true"
android:descendantFocusability="blocksDescendants"
android:layout_alignParentLeft="true"
android:layout_height="wrap_content"
android:paddingTop="8dip"
android:paddingBottom="8dip"
android:background="#FFFFFF"
android:orientation="vertical">
<TextView
android:id="#+id/manage_member_row_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="name"
android:textSize="18sp"
android:textColor="#53585E"
android:gravity="center_vertical"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="15dp" />
<Button
android:id="#+id/manage_member_row_delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="0dip"
android:paddingBottom="0dip"
android:paddingLeft="8dip"
android:clickable="true"
android:focusable="true"
android:textSize="18sp"
android:textColor="#4E4E4E"
android:background="#EAEAEA"
android:paddingRight="8dip"
android:textStyle="bold"
android:text="REMOVE"
android:layout_alignParentRight="true"
android:layout_marginRight="15dip" />
</RelativeLayout>
//fragment_manage_members.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="activities.ManageMembersActivity$PlaceholderFragment">
<ListView
android:layout_width="wrap_content"
android:descendantFocusability="blocksDescendants"
android:layout_marginTop="0dip"
android:dividerHeight="2.0dip"
android:divider="#EEEDF3"
android:layout_height="wrap_content"
android:id="#android:id/list" />
</RelativeLayout>
The problem is that sometimes position from getView are not synchronized have that problem before..
Also note that you use a HashMap<Integer, View> just to check if the view is already there that cost a lot of memory and will cause OutOfMemoryException..
so instead of putting it in a hashMap just create a ViewHolder for all your views. and add the object of the ViewHolder to the tag of the View..
example:
#Override
public View getView(int position, View view, ViewGroup viewGroup) {
ViewHolder viewHolder = null;
if(view == null)
{
viewHolder = new ViewHolder();
view = mInflater.inflate(R.layout.chat_online_user_list_view_item, null);
viewHolder.userName = (TextView) view.findViewById(R.id.chat_online_user_name);
view.setTag(viewHolder);
}
else
viewHolder = (ViewHolder) view.getTag();
//DO THE ON CLICK LISTENER HERE
return view;
}
private class ViewHolder
{
private TextView userName;
}
I have a listview, and I am using OnItemClickListener for that listview. At the same time, in getview method of my custom adapter I am using onclicklistener for the entire row view.And I figured out that when using Onclicklisnter in custom adapter, my OnItemClickListener of listview is not triggered. I want to use both these listeners at the same time. Can anyone help me to do it? Thanks in advance.
My listview listener,
list_specialists.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
HashMap<String, String> trends_data= new HashMap<String, String>();
trends_data = specobj.get(position);
specialist.setText(trends_data.get(KEY_SPEC_TITLE));
new GetTime(BookingActivity.this).execute();
}
});
And my getview method inside custom adapter,
#Override
public View getView(final int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = convertView;
final ViewHolder holder;
if (rowView == null) {
rowView = inflater.inflate(R.layout.row_timeslot, parent, false);
holder = new ViewHolder();
holder.title = (TextView) rowView.findViewById(R.id.textView2);
holder.layout = (RelativeLayout) rowView
.findViewById(R.id.relativeLayout1);
holder.check = (org.holoeverywhere.widget.CheckBox) rowView
.findViewById(R.id.checkBox1);
rowView.setTag(holder);
} else {
holder = (ViewHolder) rowView.getTag();
}
HashMap<String, String> trends_data = new HashMap<String, String>();
trends_data = trendsobj.get(position);
holder.check.setId(position);
holder.check.setChecked(checkarry[position]);
// for managing the state of the boolean
// array according to the state of the
// CheckBox
holder.check.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
for (int i = 0; i < checkarry.length; i++) {
if (position == i) {
checkarry[i] = true;
} else {
checkarry[i] = false;
}
RefreshList();
}
}
});
holder.layout.setOnClickListener(new View.OnClickListener() { // Here I am using onclicklistener for rows's parent layout.
#Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
for (int i = 0; i < checkarry.length; i++) {
if (position == i) {
checkarry[i] = true;
} else {
checkarry[i] = false;
}
RefreshList();
}
}
});
holder.title.setText(trends_data.get(BookingActivity.KEY_TIME_TITLE));
return rowView;
}
rowlayout xml file...
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/relativeLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:focusable="false"
android:background="#drawable/list_selector"
android:orientation="vertical"
android:padding="16dp" >
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:layout_toRightOf="#+id/activity_googlecards_card_imageview"
android:text="Rate "
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#757572" />
<TextView
android:id="#+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="#+id/textView3"
android:text="AED 200.00"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/mainservice" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/activity_googlecards_card_imageview"
android:layout_marginLeft="5dp"
android:layout_toRightOf="#+id/activity_googlecards_card_imageview"
android:gravity="center"
android:text="Specialist Name"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#6945B2"
android:textStyle="bold" />
<CheckBox
android:id="#+id/checkBox1"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/activity_googlecards_card_imageview"
android:layout_alignParentRight="true"
android:focusable="false"
android:focusableInTouchMode="false" />
<ImageView
android:id="#+id/activity_googlecards_card_imageview"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:scaleType="centerCrop"
android:src="#drawable/list_dummy" />
</RelativeLayout>*
If there is any clickalbe item in the list row, whose click() action will be taking place instead of onItemClickListener. Here you have a checkbox in the row item, and if you still want to use the onItemClickListener, you must make the CheckBox not focusable in the layout as follows:
android:focusable="false"
android:focusableInTouchMode="false"