Questions tagged [fragment-backstack]

Akin to the Android Activity backstack, the Fragment backstack is a task-like stack of Fragments (specified when adding a Fragment to a page with FragmentManager). It allows a linear navigation backwards from the current visible fragment, back through a history of previous fragments in a container until you reach the base fragment.

Akin to the Android Activity backstack, the Fragment backstack is a task-like stack of Fragments (specified when adding a Fragment to a page with FragmentManager). It allows a linear navigation backwards from the current visible fragment, back through a history of previous fragments in a container until you reach the base fragment.

Links

357 questions
0
votes
2 answers

java.lang.IllegalArgumentException: Navigation action/destination

I'm building a notes application. I want to save the note when user press the back button from the createsNotesFragment and finish the createNotesFragment so that I can move to the homeFragment. The code I've used to do this is…
0
votes
1 answer

How to handle back-stack in Fragment?

case 1: I have 3 fragments A,B,C. When I am moving from A->B->C and then by pressing a save button on C fragment , I come back to fragment B and now when I press the back button at this point (in fragment B), it takes me to fragment C (C fragment is…
0
votes
0 answers

Android Navigation Component (State retained)

I am facing an issue with bottom navigation when navigating through different fragments, There are 3 fragments as follows: List, Loading & Playing When user taps on Lists, it has to go to loading and if everything goes well when loading, it moves to…
0
votes
1 answer

How to set in Android to be navigated to the same fragment every time from the bottom navigation bar?

I have 4 fragments: A, B, C and X. A, B and C are found on the bottom navigation bar, so every time I click on item A, I get the A fragment on the screen, click on B, I get B. When I click on C, I get the C fragment, which has a button, that…
0
votes
1 answer

Fragments are getting destroyed when back pressed. I want it to be not destroy when back press so that I can save the states of fragments

I created an Activity and added 3 fragments into it. One is HomeFragment, second is ProductDetailFragment, and third is CartFragment. I have added multiple quantities of a product from ProductDetailFragment and I want the quantity detail to be saved…
0
votes
0 answers

Use "replace" animation when adding fragment to backstack

I'm struggling to get the desired effect when adding a fragment to the backstack. I have tried using ft.replace as well as ft.add in the following code to add my fragment, but neither give me the desired effect. val ft =…
0
votes
1 answer

how to not detsroy the fragments opened when switching with bottom navigation buttons

In the belowcode, we have a TrendsFragment and a ProfileFragment as base fragments that will be opened with bottom navigation view. I can open a Blank Fragment and navigate to it from both of these. When I do…
0
votes
1 answer

How to get top Fragment in backstack from DialogFragment

I'm using navigation to navigate between fragments. And I have a DialogFragment, it can called from from many fragment like this: val dialog = FragmentDialog dialog.show(childFragmentManager, "home_fragment") And I want to know dialogfragment…
0
votes
1 answer

I have multiple fragments.I want to save all Instances in backstack till the home button pressed again

I tried many methods to save instances but I am confused how to save instances in backstack because no one described how to use it if there multiple fragments.my code in mainactivity below: bottomNavigationView.setOnItemSelectedListener(item -> { …
0
votes
2 answers

How can I write a single function that can be re-used by multiple fragments to navigate to a singular destination?

Let's say I have 4 fragments and navigate through them in the order A -> B -> C -> D using a NavController object. A is my home screen. I'd like to write a single function called goToA() that can be inherited and called from either B, C or D which…
Kun.tito
  • 165
  • 1
  • 7
0
votes
1 answer

Android. How to avoid fragment be recreated when back from another fragment?

I'm using MVP in my project. I have an activity. Inside this activity I'm showing fragment. Fragment contains some data, edit text, buttons etc. From this fragment it is possible to navigate to another fragment. Here is my code for showing another…
0
votes
0 answers

How to manage scroll states with Jetpcak compose?

Single activity has three screens, S1(User List) -> LazyColumn S2(FormA) -> Column(Scrollable) S3(FormB) -> Column(Scrollable) Below are four possible scenarios of visiting screens with vertical position of scroll sate mentioned in the round…
0
votes
1 answer

Keep ViewModel instance when navigating back with by navGraphViewModel

So I am following Google's approach where you use single activity for the whole app and multiple view models, which are scoped to your nested nav graphs or fragments. And I have a problem with this approach. Let's use example provided by google docs…
0
votes
1 answer

Is there an easy way to prevent fragments from going back by using the back button on android

I am trying to figure out an easy solution without overcomplicating things on preventing certain screens in the app from going back when they use the back button of the android device however, I am not sure which approach is best in my…
KCYrgn
  • 251
  • 1
  • 12
0
votes
1 answer

How to get fragments from backstack when using Android Navigation Component?

How can I access any of the fragments in backstack when using Android Navigation Component? Let's sat you navigate to Fragment A then to Fragment B and then to Fragment C using Navigation Component. Now you want to access Fragment A or Fragment B…