How do I implement drill down (list)view?
I'd l开发者_运维知识库ike to implement drill down view in Android. Currently, onListItemClick, I refill the same list view with different data.
questions:
- any other suggestions? Something like the way it is done using UITableView on iPhone?
- is it possible to animate (push left or right) the listview fill operation?
This is actually rather easy. Just implement your main view as ViewAnimator
, add a listview to it.
then in onItemClick
in list view, just create next view, and push it into viewAnimator.
when done - call showPrevious()
and it will return to previous list view.
If you implement the detail view as a second Activity
, passing the selected item using an Intent
you'll get the animated transition between Activities. When going forward, the new Activity
zooms out from the middle of the screen and when going backward the reverse happens.
The "Android-Way" of doing this (if it's only two levels of hierarchy) would be using the ExpandableListView. You can find this in the API Demos sample project.
To implement something really identical to the iPhone behavior, I am sure you must go the hard way of implementing this yourself.
- Option A: implement distinct Activities for each level of hierarchy (maybe using ListActivities) and push the data in there manually
- Option B: maybe it is possible to implement sliding in and out of data through a SlidingDrawer. I am not sure though, haven't used it so far.
Seems to be tough to implement this in Android. Let's see what others suggest!
精彩评论