开发者社区> 问答> 正文

expandablelistview中自定义的child无法点击

写了一个自定义的expandablelistview
group设置监听事件,能被点击
child setOnChildClickListener()无反应 什么原因???

下面是适配器中getchildView()的函数
试了一下 把return换成title(title是自定义布局中的一个textview) 可以进行点击
怎么回事????

        public View getChildView(int groupPosition, int childPosition,
                boolean isLastChild, View convertView, ViewGroup parent) {
            View view = convertView;
            if (view == null) {
                //LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                LayoutInflater inflater = LayoutInflater.from(getActivity());
                view = inflater.inflate(R.layout.childitem, null);
            }
            final TextView title = (TextView) view
                    .findViewById(R.id.child_text);
            title.setText(childData.get(groupPosition).get(childPosition)
                    .get("child_text1").toString());
            final TextView title2 = (TextView) view
                    .findViewById(R.id.child_text2);
            title2.setText(childData.get(groupPosition).get(childPosition)
                    .get("child_text2").toString());
            final TextView title3 = (TextView) view
                    .findViewById(R.id.child_text3);
            title3.setText(childData.get(groupPosition).get(childPosition)
                    .get("child_text3").toString());            
            return view;
        }


isChildSelectable()函数已设为true
         public boolean isChildSelectable(int groupPosition, int childPosition) {
            return true;
        }

展开
收起
爵霸 2016-05-30 11:01:23 1906 0
1 条回答
写回答
取消 提交回答
  • 单从上述代码来看,没什么大问题,如果点击不了,可能是你的childitem里有需要获取焦点的控件。你试着在getChildView里把整个view设置上onclick监听,看看能不能监听到

    2019-07-17 19:19:19
    赞同 展开评论 打赏
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载