I’m fairly new to android and am slowly adjusting to how android works.
I am in the process of creating an android application which uses a .net web service to pull back data from a sql database. I have two methods which return a json response with a list of custom objects.
I am parsing these into arrays of matching objects on the android client. I am looking to implement a multiple tier grid displaying information from these two arrays. The items in the first array will have child items contained within the second array.(one to many relationship)
I am guessing I will need to create two custom array adapters? (which will allow me to have custom layouts for each tier).
I have had a look around and struggled to find a comprehensive example of using the expandable list view. What data source will this expect? (some kind of hash table I would imagine?)
Does my approach above sound reasonable?
Any advice would be appreciated.
Thanks,
ExpandableListViewexpects a class which implements the interfaceExpandableListAdapteras the data source. There are several implementations included in the Android SDK. TheSimpleExpandableListAdapterwould probably get you up and running the fastest, it uses Lists and Maps for it’s data. It won’t give you the ability to use different layouts for each group within the list but it will let you have a different layout for groups and children.If
SimpleExpandableListAdapterisn’t enough then you are going to want to write your own adapter. I’d suggest extendingBaseExpandableAdapter(this Adapter implementsExpandableListAdapterand takes care of some of the housekeeping aspects for you, it leaves the rest of the implementation to you). There is a simple example that shows how to do this in the API Demos ExpandableList1.java example.Your implementation will likely be more complex than the example, but it should give you some idea how to do it.