I have a ListView in my ListView show ImageButton.
I set focusalble \"false\" and focusableInTouchMode \"false\" to ImageButton.
I s
Actually nothing is wrong. What you are doing is ok. But i think you forgot one key factor here ImageButton has it's own OnClickListener. So when you embed your ImageButton into the listview row ListView.OnItemClickListner is not working because the click/touch is invoked by ImageButton, it's because of that ListView is not getting your click/touch event. Checkout this link: How to fire onListItemClick in Listactivity with buttons in list?
android:focusable="false"
android:focusableInTouchMode="false"
doesn't work for ImageButton.
In your layout xml, add this property to root layout
android:descendantFocusability="blocksDescendants"
It works perfectly for a listview that has ImageButton.
May be you have written onclick listener for the image button in adapter class
Example :
imageButton.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v) {
}
});
If you set onclick listener for the listItem .It will automatically consume the action input so the list item may not be clicked.
I guess you are using customize list view Item just try to set
set focusable
"false" and focusableInTouchMode
"false" for all view in your custom_list_view_item.xml
Don't worry about your image button if you using click listener for image Button in adapter, It will also work fine. just do focusable
"false" and focusableInTouchMode
"false" for all view in your custom_list_view_item.xml
If you are using custom Listview
and in the custom Listview
row item list if only Textview
and Imageview
, you should remove android:inputType=""
. It cause problem of focusability.
You are not the only sufferer :) This behavior is often considered as a bug by Android developers Have a look at this link of their conversation.
To solve your problem- simply include android:descendantFocusability="blocksDescendants"
attribute in your root layout.