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
2
votes
2 answers
ViewPager and RecyclerView issue with fragment transition
The setup is like so:
Single activity app (MainActivity) with nav_graph
HomeFragment has viewPager2 with 3 subfragments
Each of these 3 fragments are same fragment with RecyclerView showing different list of posts
User can click on a post and…

obey
- 796
- 7
- 16
2
votes
1 answer
Fragment$Companion cannot be cast to androidx.fragment.app.Fragment on BottomNavigationView listener
My bottom navigation view should work with tabs, but in some way I cannot cast
fragment as Fragment
anymore with AndroidX
There is crash every time when I click on menu item
java.lang.ClassCastException:…

Yevhen_Radchenko
- 965
- 8
- 15
2
votes
0 answers
How I set an animation on the PopBackStack() function?
On navigation from 1 fragment to another I am using slide animation.
So, when i use the PopBackStack function, it moves from the left to the right like i was not going back, but moving forward. I mean, when i slide the page back it slide out to left…

Guillermo Ferreira
- 21
- 2
2
votes
0 answers
instantiateItem nor getItem are called on FragmentPagerAdapter
I've one activity with a viewpager with a custom FragmentAdapter.
Here is my adapter code:
this.viewPager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {
SparseArray> registeredFragments = new…

Rafael Lima
- 3,079
- 3
- 41
- 105
2
votes
0 answers
How to have FragmentNavigation#navigate() behavior with FragmentTransaction#add() instead of #replace()
I am working around to preserve the view (without storing as local variable) of fragment and in current Navigation Component it looks certain that onDestroyView() is called, I want to avoid calling onDestroyView() with Android Navigation but there…

erluxman
- 18,155
- 20
- 92
- 126
2
votes
3 answers
Activity getting Destroyed when calling Fragment
Using Fragment in Class which is sub class of
RoboActivity, Crashing application when Fragment
Transaction begin;
I am also can't able to use Bottom navigation or
Tablayout, maybe it's something relates roboguice.
This is Obd car Scan…

Harsh ramani
- 41
- 1
- 11
2
votes
0 answers
Android target SDK moved from 26 to 28, error: The specified child already has a parent. You must call removeView() on the child's parent first
On our project, we have some downtime and decided to update the project target SDK version from API 26 to API 28. The project builds and works somewhat fine. The problem that we have is that we get this error when we switch back to a fragment that…

AaBoy
- 53
- 5
2
votes
1 answer
Android remove transaction from back stack
I have 3 fragments, and I'm navigating using bottom menu (3 items), lets say I navigate this way :
A -> B -> C -> B -> C
when I press the back button, that's what will happen
A <- B <- C <- B <- C
and what I want is this
A <- B <- C
that's mean…

Abdel
- 1,005
- 2
- 11
- 24
2
votes
1 answer
Fragment inside a DialogFragment, blank screen
I have a dialog fragment(FragmentA), with a frame layout.
I am trying to add another fragment(FragmentB) into the frame layout.
public void setFragment(Fragment fragment) {
FragmentTransaction transaction =…

Mukarram Ali
- 387
- 5
- 24
2
votes
1 answer
commit a fragment transaction with full screen fragment
I have a fragment (Fragment A) and it is not a full screen and I want to open from it another fragment (Fragment B) that fills the whole screen, without knowing the container id
Click on the following link to see an image that clarifies the…

Hazem Madkour
- 21
- 3
2
votes
3 answers
fragment blinks/flashes after calling replace() method
I have a MainActivity, that is supposed to switch between two fragments: Content and Settings (extends PreferenceFragmentCompat). Everything worked fine, but recently I implemented Dagger 2 dependency injection, and my Settings fragment started to…

Dmitry Smolyaninov
- 2,159
- 1
- 18
- 32
2
votes
1 answer
Back doesn't work in inner fragment
There is an activity in which there is a fragment, let's call it FirstFragment. There is a framelayout in this fragment containing another fragment, SecondFragment. By clicking on SecondFragment, ThirdFragment is fired. Here, I need to be able to go…

Arya Sadeghi
- 480
- 2
- 16
2
votes
0 answers
FragmentManager.getFragments can only be called from within the same library group (groupId=com.android.support)
Using FragmentManager.getFragments() shows an error on Android Studio. Despite this, it compiles and works properly.
This is the error:
FragmentManager.getFragments can only be called from within the same library group…

kike
- 4,255
- 5
- 23
- 41
2
votes
1 answer
What causes a fragment created by a FragmentPagerAdapter to still be known to FragmentManager after the adapter calls onDestroy?
I have a standard FragmentPagerAdapter subclass that implements getItem and getCount. The adapter has 3 items, so when the third is reached, the fragment for the first item should be destroyed.
I have verified that destroyItem is called for position…

androidguy
- 3,005
- 2
- 27
- 38
2
votes
2 answers
how to remove fragment over an activity layout
I am really new to android development. I have created a simple main activity and add an icon on top left. Clicking it I can show a blank fragment.on my screen replacing a layout which is loaded in onCreate method. Now clicking another icon I…

nimra asad
- 179
- 6
- 18