OnItemClickListener doesn't work with ListView item containing button

后端 未结 8 1807
广开言路
广开言路 2020-12-01 17:33

I have ListView with custom Adapter which supplies View to ListView in this way:

   public View getView(i         


        
8条回答
  •  悲哀的现实
    2020-12-01 18:14

    If you have ImageButtons inside the list item, you need to add:

    android:descendantFocusability="blocksDescendants"
    

    to the root list item element [such as the root layout].

    Then within each ImageButton in the list item, you need to add:

    android:focusableInTouchMode="true"
    

    This worked for me - but I was using ImageButtons, not the standard button.

提交回复
热议问题