擴展這樣與BaseExpandableListAdapter和ovverride getChildView(...)和getGroupView您的自定義適配器(...):
public View getChildView(int groupPosition, final int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
tempChild = (ArrayList<String>) Childtem.get(groupPosition);
TextView text = null;
if (convertView == null) {
convertView = minflater.inflate(R.layout.childrow, null);
}
text = (TextView) convertView.findViewById(R.id.textView1);
text.setText(tempChild.get(childPosition));
convertView.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Toast.makeText(activity, tempChild.get(childPosition), Toast.LENGTH_SHORT).show();
}
});
return convertView;
}
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = minflater.inflate(R.layout.grouprow, null);
}
((CheckedTextView) convertView).setText(groupItem.get(groupPosition));
((CheckedTextView) convertView).setChecked(isExpanded);
return convertView;
}
查看完整的示例源代碼here
來源
2017-08-23 04:08:18
sns
訪問https://開頭的github .com/tjerkw/Android-SlideExpandableListView –