[Android] ExpandableListView 子目录点击不响应,解决

来源:互联网 发布:mysql gtid复制原理 编辑:程序博客网 时间:2024/05/22 05:16
在每个itemView中都包含其他的组件,特别是button,button和listView的共存问题在这里也是不可避免的需要解决,方法比较简单,即:
在item的布局文件中的顶层Layout添加属性:
android:descendantFocusability="blocksDescendants"
这个是设置该layout下面的子view无法获取focus,我记得在测试的时候这设置就可以了,但是网上很多说法都是在button属性里也要设置如下属性:

android:focusable="false"

-----------------------------------------------------------------

class ExpandableAdapter extends BaseExpandableListAdapter
{

..........

@Override
    public boolean isChildSelectable(int groupPosition, int childPosition)
    {
        return true;

//这里默认返回false,我们需要改成 true
    }

}


原创粉丝点击