问题描述
- 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; }
解决方案
单从上述代码来看,没什么大问题,如果点击不了,可能是你的childitem里有需要获取焦点的控件。你试着在getChildView里把整个view设置上onclick监听,看看能不能监听到
解决方案二:
是childitem里的button截获了焦点
时间: 2024-08-17 15:07:36