FragmentManager is an interface for interacting with Fragment objects inside an Activity in Android. While the FragmentManager API was introduced in HONEYCOMB, a version of the API at is also available for use on older platforms through FragmentActivity. For more information about using fragments, read the Fragments developer guide.
Questions tagged [fragmentmanager]
700 questions
4
votes
1 answer
Why is activity's onBackPressed not getting called?
I am overriding the onBackPressed method in activity:
@Override
public void onBackPressed() {
super.onBackPressed();
}
And I am adding up fragments as follows:
fragmentManager.beginTransaction()
.add(R.id.frame_container,…

pagalpanda
- 150
- 2
- 16
4
votes
1 answer
OnResume called multiple times inside fragment
I have InnerFragment containing RecyclerView, inside MainFragment which is added to ViewPager.
When MainFragment gets created while swiping OnResume is called multiple times
1st time : OnResume called once in MainFragment and Once in InnerFragment…

touchchandra
- 1,506
- 5
- 21
- 37
4
votes
1 answer
No view found for id when popping backstack without adding to backstack
I am working on an Android app and have encountered an error involving Fragments and FragmentTransactions. I have created an example app to demonstrate the problem. Here is what I am doing:
add Fragment1 to fragmentSpace, without adding to…

Mitch Talmadge
- 4,638
- 3
- 26
- 44
4
votes
1 answer
Android: Difference between ft.remove() and popBackStack()
I am trying to remove a fragment from my stack. I am using this code:
FragmentManager fm = getSupportFragmentManager();
if (fm != null) {
FragmentTransaction ft = fm.beginTransaction();
Fragment currentFragment =…

user3773337
- 2,086
- 4
- 20
- 29
4
votes
1 answer
Android adding Fragment inside Fragment
Hi there (and thanks in advance),
I have an application with a Google Play Store-like layout (using PagerTabStrip with 5 sub fragments). In some of those fragments I will need to display a little info regarding the last time the data was updated.
I…

Bernardo
- 531
- 1
- 13
- 31
4
votes
0 answers
Asyncronious FragmentManager commit
I know this issue was asked before, but I couldn't find any usable answer for my problem. Imagine application, which uses Google.Volley library for RESTful api. When app launches MainActivity shows dialogFragment(Loading) and when response comes, I…

beretis
- 899
- 1
- 9
- 24
4
votes
3 answers
Call Method in Fragment from Unrelated Class
Tricky question here, but I will try and be clear.
Class A: extends FragmentActivity and has the FragmentManager
Class B: extends Fragment and has the fragment's UI
Class C: Unrelated Class
public class A extends FragmentActivity{
…

Evorlor
- 7,263
- 17
- 70
- 141
3
votes
5 answers
bottom navigation view fragment re-created when it is already created
In my application i am using Jetpack Navigation with BottomNavigationView. I have like 4 fragments:Home,Search,Notifications,Profile and when i am in Home fragment, i click again home item in bottom navigation view, it re-creates the fragment. I…

nasibeyyubov
- 1,735
- 3
- 11
- 28
3
votes
1 answer
How to get a FragmentManager for DialogFragment in Kotlin using Androidx?
I am following a tutorial where the instructor is using the Android support library v7. In my app I am using the androidx version (as suggested on the Android Developer website). When I type the lines of code as instructed, Android Studio puts a…

gig6
- 307
- 5
- 16
3
votes
0 answers
Remove OnBackPressedCallback fragmentmanager
I have an activity that load data from internet and it works fine except that o have to double click back button to finish it.
I also noticed that in the activities that don't connect to internet back button works from first click.
and when…

Islam Assem
- 1,376
- 13
- 21
3
votes
1 answer
Different types of fragmentManagers
There are several different kinds of fragmentManagers in Android: parentFragmentManager, childFragmentManager, supportFragmentManager and plain fragmentManager, which is already deprecated. But what are the principal differences between them?

Ksenia
- 3,453
- 7
- 31
- 63
3
votes
1 answer
How to change the defaultNavHost among a few already created fragments?
I have a couple of fragments in my activity, each having their own Navigation Graph, they're created when the activity is created. What I want to know is how can I choose any of them to be the defaultNavHost or the PrimaryNavigationFragment after…

SIMMORSAL
- 1,402
- 1
- 16
- 32
3
votes
0 answers
How to switch between fragments forwards and backwards correctly?
I'm currently creating an activity containing a few stages.
It is supposed to start at 'stage1' and when clicking next proceed to the next stage and when clicking back go to the previous stage.
I've tried using FragmentTransaction and replace an…

androidYS
- 55
- 1
- 6
3
votes
4 answers
How to reuse a fragment
When I replace a fragment, it gets destroyed. I tried to create the fragment in activity's onCreate and hold its reference in the activity and use it when I "re show" or "reopen" it by calling replace with the reference, but that did not help and…

Kh5
- 167
- 2
- 10
3
votes
1 answer
Invoking a fragment from another fragment and then replacing its layout
I am rather new to android development and have a problem with the invocation/replacement of fragments. My issue is very similar to this one: Android - fragment .replace() doesn't replace content - puts it on top. The "solution" to this was however,…

P. Stephani
- 43
- 7