寫了一個自定義的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監聽,看看能不能監聽到