fragment-backstack

Back button behaviour on activity to fragment in bottom navigation view

浪尽此生 提交于 2021-01-29 11:05:14
问题 I have a bottomnavigationview containing 5 fragments,(Consider A(Home), B, C, D, E) If I go to fragment D and then an Activity (Which is inside fragment D or C or any of 5) and press back button of the device. It is directly going to Home fragment(A), actually, it should go to fragment D or C. I have used botomnavigationview in my previous project but all things were working fine. Happening-- MainActivity+HomeFragment (A)---> Fragment D-->>Activity--->>OnbackPressed--->>HomeFragment Expected-

TabLayout ViewPager Not Loading When Using Backstack [duplicate]

百般思念 提交于 2020-01-31 11:07:05
问题 This question already has an answer here : Lifecycle of a replaced ViewPager and BackStack? (1 answer) Closed 4 years ago . I'm using a TabLayout in one of my fragments with a viewPager to switch between two fragments below the tabs. When I click the FAB inside one of the lower fragments, I load a new fragment (for input). However- when I press the BACK button, the TabLayout shows up but WITHOUT either of the lower fragments (represented by the pages). So what am I doing wrong? and is there a

Save state of fragments in backstack

为君一笑 提交于 2020-01-03 13:40:09
问题 My problem is generally described in this question: Once for all, how to correctly save instance state of Fragments in back stack? But i can't understand how the accepted answer is related to it. To keep it short: There are 2 fragments A and B. I go from A to B using transaction.replace() and add transaction to backstack. I rotate screen -> fragment A is not visible, but it's onSaveInstanceState is called - everything ok up to this point. I rotate screen again. Again A's onSaveInstanceState

Separate Back Stack for each tab in BottomNavigationView Android using Fragments

谁都会走 提交于 2019-12-29 03:30:49
问题 I'm implementing BottomNavigationView for navigation in an Android app. I am using Fragments to set the content for each tab. I know how to set up one fragment for each tab and then switch fragments when a tab is clicked. But how can I have a separate back stack for each tab? Here is the code to set up one fragment: Fragment selectedFragment = ItemsFragment.newInstance(); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.replace(R.id.content,

Back navigation with Fragments / Toolbar

家住魔仙堡 提交于 2019-12-22 05:25:11
问题 I'm scratching my head with this one now.... I have an ActionBarActivity that loads an initial Fragment - the original menu is inflated within the activity. Now, I have a navigation bar that, when an item is selected, loads a different fragment and adds this to the backstack. When I do this, there are a couple of things I want to set: Set the home as up indicator Invalidate the options menu from the main activity Set has options to true for the Fragment Ensure that the up indicator correctly

Android Fragment Back Stack

大城市里の小女人 提交于 2019-12-22 03:48:14
问题 I have used multiple Fragments in my Project. I want to save a Fragment's state and restore this state when I come back to this. In this Fragment I show multiple images which change on button click. I use the following code for this: String backStateName = fragment.getClass().getName(); FragmentManager fragmentManager = getSupportFragmentManager(); boolean fragmentPopped = fragmentManager.popBackStackImmediate(backStateName, 0); if (!fragmentPopped) { FragmentTransaction fragmentTransaction =

Fragments BackStack. Fragments overlap even after pop.

杀马特。学长 韩版系。学妹 提交于 2019-12-21 20:45:55
问题 The problem is to manage properly back stack so the previous fragment is poped out (or deleted). The problem is in their overlapping.. The structure of program as follows: sliding menu with 3 fragments for each section: CatalogFragment , NewsFragment , BlogFragment ; each fragment is a listView with items (parsed from JSON); on CatalogFragment 's item click I need to replace this CatalogFragment with LessonsFragment , which is list also. p.s. Items is in russian but I think you can understand

All Editexts be replace by same value after pop a Fragment

谁说我不能喝 提交于 2019-12-20 07:50:06
问题 I have a strange issue, I have 2 fragment, in first fragment, I have some custom EditText , and a button to replace this by second fragment ( addToBackStack = true), then, in second fragment, I try to using popBackStack() to back to first fragment, the issue occur, all custom EditText have same value. Below is all my code FirstFragment class FirstFragment : BaseFragment() { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { return

Is this the right way to clean-up Fragment back stack when leaving a deeply nested stack?

我与影子孤独终老i 提交于 2019-12-17 02:33:41
问题 I'm using the Android Compatibility library to implement fragments and have extended the layout sample so that a fragment contains a button which fires off another fragment. In the selection pane on the left I have 5 selectable items - A B C D E . Each loads up a fragment (via FragmentTransaction:replace ) in the details pane - a b c d e Now I've extended fragment e to contain a button which loads up another fragment e1 also in the details pane. I've done this on fragment e 's onClick method

App crash by “back” to maps fragment

╄→尐↘猪︶ㄣ 提交于 2019-12-13 15:27:36
问题 I working on my first app and got problems with the "back" function. When i open the app an click in the menu to another fragment (2,3 or 4) and i push the back button the app crashes. When i start the app and click 2 > 3 > 4 (in this order) in the menu and push the back button i go back to 3 > 2 > crash . The app crashes when i go back to the mainFragment which contains a google map. I think my problem has something to do with the googlemap in this fragment (the fragment to navigate back to)