2

I need to have a 3 level 'drill down' listview in my Android app with the back button used to go 'up' a level and wanted to know what's the best practice to do this. The data will be coming from a local SQLite database.

From what I've read, I think I have two choices.

  1. Implement each level of the listview as a seperate activity and start each activity as an intent passing the value that was selected at the previous level/activity.

  2. Implement one activity (which can call itself passing the value of the listview to show) and use a switch statement to handle setting up the view for this levels row and data adapter.

I'm open to using either, although I'm slightly leaning towards option 2 as I feel creating three layouts for what are essentially identical screens is a bit of a waste.

Any suggestions on which method is better and anything to watch out for would be greatly appreciated.

Thanks,

NiVZ

NiVZ
  • 21
  • 4

2 Answers2

0

I would go with option 2 as well. It is much neater.

With the first option you will have the problem of propogating the results back to the first activity in case you want to know what happened in the third list.

Also have you thought about using the ExpandableListView? by default it supports only two levels though..

bluefalcon
  • 4,225
  • 1
  • 32
  • 41
0

It really depends on how different the three screens are. If they are only different in content (different image, text, etc) as it sounds like from your question, you should go with one activity. If you have changes in layout between the 3 screens, at least use multiple layout XML files. This will make it easier to skin later on. It is really up to you though, there wouldn't be much performance benefits either way. If you feel the code of your class would be essentially the same, then one activity is appropriate, otherwise, use multiple activities

Rado
  • 8,634
  • 7
  • 31
  • 44