I used a hashmap to store references of all children when they were created in getChildView
. In my custom adapter, I declared:
private HashMap<String, View> childviewReferences = new HashMap<String, View>();
public View getChildView(int groupPosition, int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
final String childStr = (String) getChild(groupPosition, childPosition);
LayoutInflater inflator = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);//context.getLayoutInflater();
convertView = inflator.inflate(R.layout.childlayout, null);
TextView textview = (TextView) convertView.findViewById(R.id.childname);
textview.setText(childStr);
childviewReferences.put(Integer.toString(groupPosition) + Integer.toString(childPosition), convertView);
return convertView;
}
Child OnClick Listener
list.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
CreatePizzaAdapter adapter = (CreatePizzaAdapter) parent.getExpandableListAdapter();
View conv = adapter.getChildviewReferences().get(Integer.toString(groupPosition) + Integer.toString(childPosition));
//now you can find any view and child and do anything
return true;
}
});