OnItemCLickListener not working in listview

前端 未结 24 1929
悲&欢浪女
悲&欢浪女 2020-11-22 11:21

Activity class code:

conversationList = (ListView)findViewById(android.R.id.list);
ConversationArrayAdapter conversationArrayAdapter=new  Conver         


        
相关标签:
24条回答
  • 2020-11-22 11:31

    use the below code inside button tag in custom row layout of listview

     android:focusable="false"
     android:clickable="false"
    
    0 讨论(0)
  • 2020-11-22 11:36

    Use android:descendantFocusability

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="80dip"
        android:background="@color/light_green"
        android:descendantFocusability="blocksDescendants" >
    

    Add above in root layout

    0 讨论(0)
  • 2020-11-22 11:38

    The problem is that your layouts contain either focusable or clickable items. If a view contains either focusable or clickable item the OnItemCLickListener won't be called.

    Click here for more information.

    Please post one of your layout xmls if that isn't the case.

    0 讨论(0)
  • 2020-11-22 11:39

    Android:autoText attribute also makes TextView auto focusable.

    0 讨论(0)
  • 2020-11-22 11:41

    I had the same issue, I was using a style for my texts in the row layout that had the "focusable" attribute. It worked after I removed it.

    0 讨论(0)
  • 2020-11-22 11:43

    All of the above failed for me. However, I was able to resolve the problem (after many hours of banging my head - Google, if you're listening, please consider fixing what I encountered below in the form of compiler errors, if possible)

    You really have to be careful of what android attributes you add to your xml layout here (in this original question, it is called list_items.xml). For me, what was causing the problem was that I had switched from an EditText view to a TextView and had leftover attribute cruft from the change (in my case, inputType). The compiler didn't catch it and the clickability just failed when I went to run the app. Double check all of the attributes you have in your layout xml nodes.

    0 讨论(0)
提交回复
热议问题