How to sort groups and children Expandable listview in Android?

前端 未结 3 2049
伪装坚强ぢ
伪装坚强ぢ 2021-01-22 10:26

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

3条回答
  •  北恋
    北恋 (楼主)
    2021-01-22 10:57

    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.

提交回复
热议问题