Hi folks,

I'm porting an iPhone app that was based on the navigation template.
I.e. a series of views are pushed onto a navigation stack, and the bar
at the top shows where you're at in the hierarchy.  I go deeper into
the hierarchy by interacting with things on each view, and I go
backwards in the stack by pressing the back button on the navigation
bar.

On Android I've ported it so that each step in the hierarchy is a new
activity with its own custom layout.  Each one though has a bar at the
top that shows the title of the previous screen and the current
screen.  I go forwards still by interacting with stuff on the layout
(tapping a cell in a ListView for example), and I go backwards using
the hardware back button.  This all works well for me right now.

My problem now is what to do with scenarios where I want to completely
clear the stack and return to the "home" or root screen/activity.  How
do I finish/kill off all the other activities in the stack when I want
to pop straight to the root no matter my current depth?

I was thinking one way would be that I could keep a literal stack,
implement it as a singleton, and every time one of my stack based
activities is created it would add itself to the stack, and when it's
destroyed it would remove itself from the stack.  When I want to pop
to the bottom I would then just iterate through the stack and call
finish() on each of the items.  Does this make sense?  Is there a
better way?

Thanks in advance for any advice.

-- 
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

To unsubscribe, reply using "remove me" as the subject.

Reply via email to