Tuesday, April 10, 2012

Android Search Expandable ListView

I am building my first android app and I encountered a problem. In the app I have a search function that uses a ListView. Here users can search for a certain item and see if it exists. This works really well and I did it based on this tutorial: Android ListView with Search



All my items are found in a string array defined in array.xml. Now, every item can be part of one or more collections. Currently I show the collections it is included in next to the item's name, like this: "ITEM -> Collection(s)". This works but is not really an elegant option. What I would like to do is have the item's name as the ITEM in an expandable ListView and the collections it belongs to as a SUBITEM. I would therefore have 2 string arrays, one for the parent items, one for the children items.



All the examples I have found are populating the list "manually" and I can not figure out how to assign my ITEMS array to the GROUP and my COLLECTIONS array to the CHILDREN.



I don't know if I explained this clearly enough but in short, it would be like this:



ITEM_1 = 1st Group name
COLLECTIONS_1 = 1st Group's child



Example Image



Thank you!





No comments:

Post a Comment