开发者

Android - CheckBox blocks ExpandableListView.OnGroupClickListener

开发者 https://www.devze.com 2022-12-10 20:47 出处:网络
I\'m trying to put a checkbox into ExpandableListView. How do I do that? I extend BaseExpandableListAdapter and put the following into getGroupView():

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? Tha开发者_开发知识库t'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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消