ListView OnItemClickListener is not listening

前端 未结 1 1232
礼貌的吻别
礼貌的吻别 2021-01-29 05:24

I checked all the previous questions regarding this issue , but none of them are helpfull to me .

My listview is not responding , i tried changing this list.set

相关标签:
1条回答
  • 2021-01-29 06:18

    If any row item of list contains focusable or clickable view then OnItemClickListener won't work such as for checkbox or button etc in the row item.There are two solution:

    1. row item must be having param like android:descendantFocusability="blocksDescendants"

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:baselineAligned="false"
        android:descendantFocusability="blocksDescendants"
        android:gravity="center_vertical" >
    
        // your other widgets here
    
    </LinearLayout>
    

    2. Set given two attributes to false like

     android:focusable="false"
       android:focusableInTouchMode="false"
    

    For example if there is any checkbox or button or image in the row item then

    <CheckBox
        android:id="@+id/fav_check_box"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:focusable="false" />
    
    0 讨论(0)
提交回复
热议问题