1

I have an ExpandableListView and everything is ok. I have a checkbox in each child row that I want to toggle when I click on a child row as below:

expandableListView.setOnChildClickListener(new OnChildClickListener() {
    @Override
    public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
        CheckBox checkBox = (CheckBox) v.findViewById(R.id.checkBox1);
        checkBox.toggle();
        return true;
    }
});

The problem is that program never enters inside onChildClick() event handler. Any Idea?

Ali Behzadian Nejad
  • 8,804
  • 8
  • 56
  • 106

3 Answers3

5

Try this,

set android:focusable=false for the check box. If it still doesn't work then add,

android:descendantFocussability=blocksDescendants to the top most layout.

Andro Selva
  • 53,910
  • 52
  • 193
  • 240
1

Don't forget to Enable

@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
    // TODO Auto-generated method stub
    return true;
}
Swap-IOS-Android
  • 4,363
  • 6
  • 49
  • 77
1

As stated here, you might have to add the following lines to your checkbox:

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

With this I could simply use the OnChildClickListener of the ExpandableListView

Community
  • 1
  • 1
bergjs
  • 125
  • 2
  • 6