hi guys trying change value of parent clicking child in expandable list. have looked solution cant find anything.
public boolean onchildclick(expandablelistview parent, view v, int groupposition, int childposition, long id){ expandablelistadapter itemadapter = parent.getexpandablelistadapter(); string selecteditem = (string)itemadapter.getchild(groupposition, childposition); groupheader(selecteditem); if(parent.isgroupexpanded(groupposition)){ parent.collapsegroup(groupposition); } return true; } });
an expandablelistview depends on adapter obtain values. values come sort of data structure, arraylist or simple array. in onchildclick(), pass reference data structure used build expandablelistadapter , modify data structure directly, followed call notifydatasetchanged().
public boolean onchildclick(expandablelistview parent, view v, int groupposition, int childposition, long id) { expandablelistadapter itemadapter = parent.getexpandablelistadapter(); string selecteditem = (string)itemadapter.getchild(groupposition, childposition); groupheader(selecteditem); if(parent.isgroupexpanded(groupposition)) { parent.collapsegroup(groupposition); } // logic here // expandablelistarraylist.add() or expandablelistarraylist.remove() // or whatever itemadapter.notifydatasetchanged(); return true; } });
you have extend adapter create functionality need. question bit nebulous because can't see overall structure of code, should give running start.
Comments
Post a Comment