★ Android ExpandableListView中子元素无法点击 解决方案!

这几天公司写个电商项目,写道购物车页面,发现ExpandableListView点击子类的方法无效!!

解决方法
【1】首先检查购物车中的Adapter中isChildSelectable 方法是否为true

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

【2】查看子类View中是否有Edittext CheckBox这类抢夺焦点的控件,(我这里就有个CheckBox)如果是Edittext 记得加上Edittext的父布局上加上

android:focusable="true"
android:focusableInTouchMode="true"

在这里插入图片描述
【3】 如果View中带有 抢夺焦点的控件 使用android:focusable=“true” 以然没有效果,那就检查一下看是哪个View lickable为true ! 去掉即可

【4】这里我要说的就是它了,我出现的问题就是前三个方法都试验了,可结果依然不好用! 在子类的View布局的顶上加上 获取焦点!

android:descendantFocusability="blocksDescendants"

最后看一下效果图

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/MacaoPark/article/details/87869249