2
votes

I have 3 actionbar tabs at the top of my main activity, and a fragments for each tab. I have a few questions regarding such a design and how to open new activities from it.

I have a button in my first tab fragment that I need to open a new activity, but I want the tabs to remain. Here is an image to demonstrate:

enter image description here

If you are on fragment 1 and you press the button to open the new activity, the back button should simply return you to fragment 1. However, if you are on fragment 1, you press the button to go to the new activity and then navigate to a different tab, pressing the back button should do nothing. I hope this makes sense. What is the best way to achieve this?

1
You shouldn't do this - it is a common Navigation Anti-Pattern - ianhanniballake
Ian, thankyou that video you posted is a great help. I didn't realise that it was a no-no but it makes sense now. If you submit it as an answer I will accept it. - user1636130

1 Answers

2
votes

You shouldn't do this - it is a common Navigation Anti-Pattern. Instead, you should consider taking the user to a new screen (whether that is a new activity or a fragment that replaces everything visible including the tabs).