Reputation: 2232
I created a ListView inside of a LinearLayout which again is in a Tab. The list is basically a list of categories which further open into other lists. How I did this is that I just put an OnItemClickListener and after a category is clicked I used removeAllViews() on the LinerLayout and then again added a new ListView of the respective category.
The problem is that pressing the back button from inside a category doesnt go back to the first list, but completely before when there was a list, as the whole thing is occuring in a single Activity. So is it possible to stop that from happening?
Upvotes: 2
Views: 103
Reputation: 16354
Use onBackPressed
to override the action of the BackButton.
@Override
public void onBackPressed() {
// do something when the BackButton is pressed
// what you can do is again removeAllViews() from the LinearLayout and redraw your first list
return;
}
Upvotes: 2