fragment-backstack

TabLayout ViewPager Not Loading When Using Backstack [duplicate]

。_饼干妹妹 提交于 2019-12-03 14:21:49
This question already has an answer here: Lifecycle of a replaced ViewPager and BackStack? 1 answer 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 better way to be swapping fragments ? and is there a way to press the back button and get back to the viewPager Page that was

Android - Back button and fragment backstack not working

被刻印的时光 ゝ 提交于 2019-12-03 07:48:38
I'm developing a simple fragment-based application with a singe FragmentActivity. Each 'screen' of the application is contained in a fragment and all fragments are added to the container layout at application startup. // Set up fragments in Main Activity fragMan = getFragmentManager(); FragmentTransaction ft = fragMan.beginTransaction(); ft.add(R.id.fragment_container, settingsFragment); ft.add(R.id.fragment_container, mapFragment); ft.add(R.id.fragment_container, tracksFragment); ft.add(R.id.fragment_container, waypointsFragment); ft.commit(); Transitions are accomplished by hiding the

All Editexts be replace by same value after pop a Fragment

末鹿安然 提交于 2019-12-02 13:56:14
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 inflater.inflate(R.layout.fragment_first, container, false) } override fun onViewCreated(view: View,

Prevent The Same Fragment From Stacking More Than Once ( addToBackStack)

◇◆丶佛笑我妖孽 提交于 2019-11-30 19:53:17
I have an Activity with three Fragments lets call them A , B and C . Fragment A is called in the Activity onCreate() . FragmentA fragA = new FragmentA(); FragmentTransaction transaction = manager.beginTransaction(); transaction.add(R.id.activity2_layout, fragA, "A"); transaction.commit(); And gets replaced with Fragment B or C when certain buttons are pressed, and the FragmentTransaction calls addToBackStack() . FragmentB fragB = new FragmentB(); //or C FragmentTransaction transaction = manager.beginTransaction(); transaction.replace(R.id.activity2_layout, fragB, "B"); //or C transaction

How to delete a specific fragment from back stack in android

*爱你&永不变心* 提交于 2019-11-30 04:47:09
I have a problem about removing a specific fragment from back stack.My scenario is like this.Fragment-1 is replaced with Fragment-2 and then Fragment-2 is replaced with Fragment-3. Calling order; Fragment-1-->Fragment-2-->Fragment-3. When Fragment-3 is on the screen and then back button is clicked, i want to go Fragment-1.That means i want to delete Fragment-2 from back stack. How to do this ? In the backstack you don't have Fragment s, but FragmentTransaction s. When you popBackStack() the transaction is applied again, but backward. This means that (assuming you addToBackStackTrace(null)

Prevent The Same Fragment From Stacking More Than Once ( addToBackStack)

为君一笑 提交于 2019-11-30 03:56:58
问题 I have an Activity with three Fragments lets call them A , B and C . Fragment A is called in the Activity onCreate() . FragmentA fragA = new FragmentA(); FragmentTransaction transaction = manager.beginTransaction(); transaction.add(R.id.activity2_layout, fragA, "A"); transaction.commit(); And gets replaced with Fragment B or C when certain buttons are pressed, and the FragmentTransaction calls addToBackStack() . FragmentB fragB = new FragmentB(); //or C FragmentTransaction transaction =

How to delete a specific fragment from back stack in android

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-29 02:12:14
问题 I have a problem about removing a specific fragment from back stack.My scenario is like this.Fragment-1 is replaced with Fragment-2 and then Fragment-2 is replaced with Fragment-3. Calling order; Fragment-1-->Fragment-2-->Fragment-3. When Fragment-3 is on the screen and then back button is clicked, i want to go Fragment-1.That means i want to delete Fragment-2 from back stack. How to do this ? 回答1: In the backstack you don't have Fragment s, but FragmentTransaction s. When you popBackStack()

How to get the current fragment displayed in a specific tab of a viewpager?

烈酒焚心 提交于 2019-11-29 01:22:09
I want to get the last fragment in the backstack, or the current displayed it's the same for me, in the tab b_1 . As you can see in the following image, I have a ViewPager, and another one inner tab b . Thus there are four current fragments displayed. Question : How can I get the Fragment 2 instance? I have seen another solutions, but none works for this scenario. Annotation: The fragment to return is not necessary the hosted in the ViewPager. I can have opened two more fragments in a tab. With this method I get all the current visible fragments, but not the one specific I want. public

Separate Back Stack for each tab in BottomNavigationView Android using Fragments

◇◆丶佛笑我妖孽 提交于 2019-11-28 18:49:25
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, selectedFragment); transaction.commit(); For an example, Fragment A and B would be under Tab 1 and Fragment C

What does FragmentManager and FragmentTransaction exactly do?

十年热恋 提交于 2019-11-27 17:35:56
I have simple code below FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.replace(R.id.fragment_container, mFeedFragment); fragmentTransaction.addToBackStack(null); fragmentTransaction.commit(); What do these lines of code do? Zelldon getFragmentManager() Return the FragmentManager for interacting with fragments associated with this activity. FragmentManager which is used to create transactions for adding, removing or replacing fragments. fragmentManager.beginTransaction(); Start a series