user1568613
user1568613

Reputation: 123

stack activity in android

Hi i am working with android , and i have a problem with the activity stack. As i know, when someone uses the back button, reload the back activity. But in the case i have many layouts shown from one activity, how can i go back to them.

Here is the deal, i am using a listview filled with categories, and when i press an item, i reuse the activity and the layout, to show its subcategories. So what i need is to came back no to the back activity, not to the back layout, but to the back "state".

Well, the idea is simple, first i show all the categories with no parent, then when i pressed an item, i show its subcategories.

Upvotes: 1

Views: 79

Answers (2)

FunkTheMonk
FunkTheMonk

Reputation: 10938

Check out Fragments, they are the stepping stone between a view and an activity. An activity can have multiple fragments and will manage their back stack (if you tell it to). http://developer.android.com/guide/components/fragments.html

You'll have to use the support library to used them on pre honeycomb devices.

Upvotes: 1

Egor
Egor

Reputation: 40203

The easiest way is creating two Activities - for categories and for subcategories. If you try to implement all the logic in a single Activity you won't earn nothing and just end up totally confused. Using Activities simplifies things a lot just because it handles problems such as yours. Hope this helps.

Upvotes: 1

Related Questions