I have two tables in mysql which bind \'Categories\' and \'products\' through ids \'id_catprods\' and \'ID_Cat\'. So far so good, I\'m working on Android with \"ExpandableListVi
Sort them when querying in MySql if possible. Otherwise, here is one suggestion. Store the categories in a ArrayList
. You can easily sort them using one of Collection.sort()
. Then, store your products in a Hashtable
where the key is the category name and the data is a Product class that stores your product details. You can sort your Product class using an Comparator
. You will need to modify the adapter accordingly.