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.
Related
My problem is illustrated by this screen record.
When I click the FAB on FinanceFragment, it will open AddTransactionFragment. But when I navigate to ReminderFragment and go back to FinanceFragment, the AddTransactionFragment is destroyed.
How could I -- similar to the YouTube app when one switches between fragments -- keep AddTransactionFragment visible while I navigate to another fragment?
I tried to add addToBackStack() but this turned out not to be what I was looking for.
I am a beginner in android. I have created Tabs using ActionBar tabs. Now I want to implement, when the user in in first tab and clicks back Button activity should close or when the user is in second tab, he clicks the backbutton the app should show the first tab, which will make it as the home tab. I tried using popupbackstack() but it always closes the activity no matter what tab i am in.
please guide me. Thanks in advance.
The easiest way would be record the tab state (i.e., which tab is showing) in the host activity, and override the onBackPressed() method to do what you want.
Some tips:
remember to save the state(override the onSavedInstanceState() and save the tab state) to make you activity works right after restore from onPause().
read about android's recommended navigation style here. What you designed is a little bit different from what android suggests.
I'm currently porting iOS App to Android
the iOS app uses tabbar + navigation controller (inside each tab) to load multiples Views
I would like to keep the same design on Android, but I'm a bit confused with it
I tried "startActivityForResult" to load another activity the TabHost is removed
I also tried to replace the view with setContentView, I'm working, but as some tabs requires more than 10 sub screen, the code will be very elegant.
So I'm looking for a solution to load another Activity in the same tab with a UINavigationController like features
Ex: If I have three tabs A, B, C, on tab A I can go to A1 while pressing some button, If I push back button, I would like A to be displayed
You can go either with Fragment or with ActivityGroup.
Fragment is the latest solution where as ActivityGroup is deprecated.
You can refer:
Activity Group => this, this, this, this
Fragment => this, this
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!
I am creating an app for Android 3.0+ that uses the action bar with tabs for navigation. I have 2 tabs that each load a ListFragment:
Tab 1 Tab2
A B
C D
Where A & C are list items in Tab 1 and B & D are list items in Tab 2.
Currently if you select Tab2 and then item B a new ListFragment is loaded on top of the current list fragment in Tab2. Pressing back takes you back to the original Tab2 contents. However if you don't press back and instead select Tab1 you see Tab1's contents on top of the new content you loaded in Tab 2. So I am guessing there is a better way of doing this. I wanted to use multiple fragments in each Tab to reduce the code complexity in each tab (for instance the onListItemSelected handling). Is there another way to do that without using multiple fragments? I am also trying to just save state but I am not sure how to tell the difference from when the user clicks back (then I would want to restore state) and the user has selected tab 1 and then selects tab 2 again (i would want to restore state).
Thanks
I am having similar struggles with the complexity of fragments and tabs on the Action bar. It seems to me that android for tablets is still very much in its infancy and there are various issues (like yours and the issues I'm having) that will be addressed in the coming months. For now, I think you just have to handle some of those complexities yourself instead of relying on the Android framework.
To answer your first question more directly, I think you need to step back and think out the functionality before diving into the code. I can give you a potential solution (keep track of your fragments manually in the activity and simply add and remove fragment as necessary via the ActionBar.TabListener interface.
Also, if you want the user to be switching from one fragment to another like you are suggesting, perhaps the back functionality shouldn't be used. What happens if the user clicks on the tabs 10 times in a row. Do you want the back button to take the user back through all of those events? I think the back button should only be used when the navigation system is very sequential and "back" is an easy concept. Check out all the Google apps that use tabs to see what I'm talking about.