I have a ListView in my ListView show ImageButton.
I set focusalble "false" and focusableInTouchMode "false" to ImageButton.
I set ListView.OnItemClickListner. When I run my project It's show my ListView.
But When I click on Listview It's not working.
Then I remove ImageButton in layout and run my project again when i click ListView It' work
What wrong ?

- 1,063
- 4
- 17
- 34
-
2how can we help you without have a code to illustrate your problem... – Coderji Nov 26 '13 at 04:08
-
set the image button to onclickable false, onfocusable false and also focusable on touch to false.. Also in the adapter set this properties. if u need to implement a click on the image button do it in the adapter class. – Rat-a-tat-a-tat Ratatouille Nov 26 '13 at 04:24
-
https://stackoverflow.com/a/17803234/4294399 – General Grievance Jul 28 '22 at 18:52
5 Answers
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.

- 3,124
- 5
- 35
- 66
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.

- 32,418
- 18
- 82
- 110

- 3,965
- 37
- 39
-
This works for me I had converted an EDITTEXT to TEXTVIEW hence this was there – Smaran Jul 29 '20 at 08:47
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?

- 1
- 1

- 1,109
- 7
- 13
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

- 6,511
- 28
- 39
- 51

- 1,362
- 13
- 24
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.

- 5,466
- 1
- 25
- 30