I have an Android app whose main activity is a tabhost.
How do I save the state of each tab? Right now, if I start at tab A, open a new Fragment C in the tab, go to tab B, then go back to tab A, I only see the original Tab A.
Tab A --> Fragment C
Tab B
How do I make it so I can see the backstack tab?
In general, if I modify the state of a tab, I want to be able to navigate away from it, come back, and see the modified state.
I'm currently detaching and attaching fragments when I switch tabs. Is this the wrong way to go about it? Is the issue something else?
Thanks!
Related
Im using NavComponent v2.4.2 with bottom navigation. Lets imagine that I have 3 tabs A, B and C. Each fragment in each tab will be called correspondendly: A1 - first fragment in first tab, B3 - 3rd fragment in second tab.
What's my problem:
Im starting the app, my destination is A1. I navigate to A2, then switch the tab to B. So now I have B1 opened. I press system back button and expect to see A2, but I see A1 (which is start destination).
Lets go back to the moment when I switched tab - Im on B1. If I choose tab A I will actually see last opened fragment - A2.
I found one solution - set menuCategory to my menu items to "secondary", which solves the problem above, but brings another - now my bottom navigation tabs doesnt save history.
I cant seem to find a solution T.T
I have a built a tab navigator in my app using react-navigation-tabs. I have three tabs which are embedded in a stack navigator.I can access the 3rd tab and access that respective screen.When I come back to the tab, I should navigate to the 3rd tab ideally. In my case, I'm landing on the first tab and have to navigate to the 3rd one all over again.
Can anyone please suggest a solution for this?
Thank you in advance.
How to implement navigation like instagram where every tab of theirs has it's own back stack?
I have a TabLayout with 5 tabs and I inflate many different fragments in each tab individually depending on user action but it all just gets added to the backStack in general, not specifically to each tab.
For example in my:
If I am in the Settings Tab-->Inflate User Frag-->Inflate Profile Pic Frag
Then I go to the Feed Tab-->Open Post Frag
Then I go back to the Settings Tab, the Profile Pic frag will still be open which is good but if I click the back button I would like it to remove the Profile Pic frag and take me back to the User Frag but instead it will remove the Open Post Frag
I've played around with FragmentTransactions and the backstack but can't seem to get it right, often the problem is too many fragments get removed when I dont want them to.
Any help will be great!
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:
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?
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).
In my app I have TabActivity , and 3 Tabs in it. Every tab has some buttons, that changes current Tabs view. I mean when I'm clicking on the button, it changes the Activity in the current Tab, but when I'm going to second Tab and returning to first one, Tab is recreating. I need to keep the Tab unchanged. How to do this?
Also I didn't use fragments because it needs min API level 11
Thanks in advance