Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - CheckBox blocks ExpandableListView.OnGroupClickListener

I'm trying to put a checkbox into ExpandableListView. How do I do that? I extend BaseExpandableListAdapter and put the following into getGroupView():

@Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView,
   ViewGroup parent) {
    View view = convertView == null ?
      context.getLayoutInflater().inflate(R.layout.onet_head, null) : convertView;
     ((TextView)view.findViewById(R.id.onetText)).setText(cats.get(groupPosition).value); 
    return view;
}

Notice that inflated layout? That's where I'm putting TextView and CheckBox. I noticed that placing a checkbox into my group row layout disables default group row functionality when clicking on the row makes a secondary (child) list appear. CheckBox is functioning as expected but when I click outside of the it the click is never detected by ether CheckBox or by OnGroupClickListener. I suspect that placing CheckBox into group row this way interferes with event detection/handling but thus far I'm not able to track it down

Can someone help me to resolve this? The CheckBox works fine though including detecting clicks when clicking directly on the box

like image 216
Bostone Avatar asked Nov 05 '09 20:11

Bostone


1 Answers

Anytime you place an item that is focusable in a list the list items no longer respond to clicks or anything like that. For every item you place in the list item that is focusable (buttons, checkboxes, etc), you need to set the android:focusable attribute to false.

I had a similar question and that was the answer for me. Android custom ListView unable to click on items

like image 190
MattC Avatar answered Oct 05 '22 22:10

MattC