ExpandableListView child click listener not firing

后端 未结 6 586
感动是毒
感动是毒 2020-12-28 14:47

Not sure why my onChildClick isn\'t firing. Everything works perfectly, except that when one of the child items is tapped, absolutely nothing happens. Otherwise, the expanda

相关标签:
6条回答
  • 2020-12-28 15:00

    Be sure to override the isChildSelectable method of your expandable list adapter and return true, like so:

    public class MyExpandableListAdapter extends BaseExpandableListAdapter {
    ...
    
    @Override
    public boolean isChildSelectable(int groupPosition, int childPosition) {
        return true;
    }
    ...
    }
    
    0 讨论(0)
  • 2020-12-28 15:00

    Checkbox should not be focuable and clickable ..

    <CheckBox
                android:focusable="false"
                android:clickable="false"
                android:focusableInTouchMode="false"
                android:id="@+id/expandedListItem"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:paddingLeft="?android:attr/expandableListPreferredChildPaddingLeft"
                android:paddingTop="10dp"
                android:paddingBottom="10dp" />
    
    0 讨论(0)
  • 2020-12-28 15:02

    I got it. All I had to do was add

    android:focusable="false"
    

    within the CheckBox section of my expandlist_child_item.xml file.

    I hope that this helps somebody.

    0 讨论(0)
  • 2020-12-28 15:19

    Checkbox should not be focusable, nor clickable.

    0 讨论(0)
  • 2020-12-28 15:26

    I think yu have to use the onItemClickListener and use the passed parameter to see if it is group click or not

    0 讨论(0)
  • 2020-12-28 15:27

    Looks all right, still:

    1. Check that you have not set a click listener to any parent view of listview.

    2. Check that isChildSelectable() of adapter returns true. Also areAllItemsEnabled() should return true.

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