adding different child lists for each parent in ExpandableListView for Android? -
i have expandable list view parent list showing store names. child element should first line of address, 1 on each. code sets parent element correctly every parent element contains of child elements rather 1 relating it.
any ideas?
private void preparelistdata() { listdataheader = new arraylist<string>(); listdatachild = new hashmap<string, list<string>>(); //system.out.println(debugname.get(i)); list<string> top250 = new arraylist<string>(); (int = 0; < debugname.size(); i++) { storename = debugname.get(i); listdataheader.add(storename); listdatachild.put(listdataheader.get(0), top250);
//store name prints so: store 1, store 2, store 3 etc. 1 each parent element.
} (int = 0; < address1.size(); i++) { storeaddress = address1.get(i); system.out.println(storeaddress);
//store address prints address store 1, 2, 3 under each parent
top250.add(storeaddress); listdatachild.put(listdataheader.get(i), top250); }
without seeing more of source code, looks me you're adding all store addresses top250
.
listdatachild.put(listdataheader.get(i), top250)
therefore assigning store addresses under each header every time.
try changing line listdatachild.put(listdataheader.get(i), top250.get(i))
, see if it's closer wanted.
of course, might not expect yet, because assumes each header has 1 address , listdataheader
items matched each top250
item can start there.
Comments
Post a Comment