Get groupposition of listview by String attached to it (android) -
i have listview elements , i'm trying implement basic search listview.
this function creates it's elements:
listdataheader = new arraylist<string>(); listdatachild = new hashmap<string, list<string>>(); int counter = 0; (int = 0; i<namesmails.size();i = i+2) { //namesmails[0] == name && namesmails[1] == phone && namesmails[2] == email string name = namesmails.get(i); string mail = namesmails.get(i + 1); string phone = returnnumber(namesphones,name); listdataheader.add(name); list<string> currentname = new arraylist<string>(); currentname.add(phone); currentname.add(mail); listdatachild.put(listdataheader.get(counter), currentname); counter += 1; }
now on search have query + know input successful (the name exists in list, don't know how access it).
if (namesmails.contains(query)){ //i want position of queryed name expand-it. //i've set static number (20) expand , select. explistview.expandgroup(20) explistview.setselection(20); }
how access expandable listview name added expand , set selected?
i got friend apparently isn't user of site if in future needs help, 1 of solutions possible. not solution out there (since there's way access children directly name) came sort of work-around.
i created additional arraylist called onlynames in beginning of class, setting global variable.
in method:
listdataheader = new arraylist<string>(); listdatachild = new hashmap<string, list<string>>(); int counter = 0; (int = 0; i<namesmails.size();i = i+2) { //namesmails[0] == name && namesmails[1] == phone && namesmails[2] == email string name = namesmails.get(i); string mail = namesmails.get(i + 1); string phone = returnnumber(namesphones,name); namesonly.add(name); listdataheader.add(name); list<string> currentname = new arraylist<string>(); currentname.add(phone); currentname.add(mail); listdatachild.put(listdataheader.get(counter), currentname); counter += 1; }
i added namesonly.add(name): namesonly has same position on names listdataheader can call out:
if (namesmails.contains(query)){ int el = namesonly.indexof(query); explistview.expandgroup(el) explistview.setselection(el); }
and worked :).
Comments
Post a Comment