I’m really not sure how to ask this question but I need a way to allow the user to switch between lists by clicking on them and pressing the ‘back’ button works naturally. For instance, I present the users with names of people, they click a name, and a new list appears containing messages from that person.
I’m doing it really poorly right now by having a single ListActivity and I use onListItemClick to listen for any click on a list. Then I call setListAdapter(someArrayList) each time the list changes.
Surely there is a much more intuitive solution than this. Could someone point me toward some tutorials on how to do this?
You basically need multiple activities, each having their own lists. Then you can start other activities by doing:
Edit – parameters for activities can be attached to the
Intentbefore callingstartActivity:and later retrieved in the next activity using:
So you would have a
PeopleActivity, aMessagesActivity, etc. and inside that activity the list would only display items pertaining to that type of information.You might want to check out Activities and Activity and Task Guidelines to get a better picture of what’s going on when you start new activities.