views:

619

answers:

1

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

+3  A: 

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. http://stackoverflow.com/questions/1121192/android-custom-listview-unable-to-click-on-items

MattC
Matt! Thank you so much, this indeed solved the problem
DroidIn.net
My pleasure. This one drove me nuts for a long time.
MattC