Android的 - 复选框块ExpandableListView.OnGroupClickListener [英] Android - CheckBox blocks ExpandableListView.OnGroupClickListener

查看:189
本文介绍了Android的 - 复选框块ExpandableListView.OnGroupClickListener的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图把一个复选框到ExpandableListView。我怎么做?我向BaseExpandableListAdapter并把下列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;
}

注意充气布局?这就是我把TextView的和CheckBox。 我注意到,放置一个复选框到我的组排布置禁用默认组排功能,当点击该行上使得二级(子)列表出现。复选框运行正常,但是当我点击它的外 点击永远不会被醚复选框或OnGroupClickListener检测。我怀疑,将复选框成组一行这种方式干扰事件检测/处理,但迄今为止我无法追查

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

推荐答案

任何时候当你把一个项目,是可聚焦在列表中的列表项不再点击或类似的东西作出反应。对于在列表项是可聚焦(按钮,复选框,等)将每一个项目,你需要到Android设置:可聚焦的属性设置为false。

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.

我也有类似的问题,这是对我的答案。 <一href="http://stackoverflow.com/questions/1121192/android-custom-listview-unable-to-click-on-items">http://stackoverflow.com/questions/1121192/android-custom-listview-unable-to-click-on-items

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

这篇关于Android的 - 复选框块ExpandableListView.OnGroupClickListener的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆