Questions tagged [fragmentmanager]

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.

700 questions
3
votes
1 answer

How to replace fragment with cointainerviewId in a Dialogbox

I have to replace id with the fragment, here is my source: public void showEmojiDialog() { final Dialog dialog = new Dialog(MainActivity.this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCancelable(false); …
3
votes
0 answers

fitsSystemWindows not working in fragments added by FragmentPagerAdapter

My app is working with a FragmentPagerAdapter to add Fragments to the ViewPager. The problem is that the property android:fitsSystemWindows="true" ist not working. It doesn't add padding to the elements. My main layout looks like…
3
votes
1 answer

IllegalStateException: Activity has been destroyed (API level <21)

I have a Single Activity App with a bottombar. Each tab of the bottombar is a fragment which acts as a container and presents several childfragments. Only on Android versions <21 the app crashes with the following stacktrace: Process: de.name.dev,…
3
votes
2 answers

Fragment transaction remove

I have a fragment, which I add with a tag like this: getSupportFragmentManager().beginTransaction().add(R.id.fragment_container,fragment,fragment_tag).commit(); At some point, in another fragment, I need to remove this fragment so I call: fragment…
Ricardo
  • 9,136
  • 3
  • 29
  • 35
3
votes
1 answer

fragment popbackstack behaviour broken in 25.1.0 and 25.1.1

Since support version 25.1.0 and the most recent 25.1.1 I got strange behaviour with fragment replacing/adding. There have been issues reported for 25.1.0 Android - fragmentTransaction.replace() not works on support library 25.1.0 But now in 25.1.1…
3
votes
0 answers

getFragmentManager() returns null sometimes

android.app.Fragment android.app.FragmentManager.findFragmentByTag(java.lang.String)' on a null object reference I had found numerous posts with this issue here on SO, but none of them helped me. It happens relatively rarely (1/100). The place…
BVtp
  • 2,308
  • 2
  • 29
  • 68
3
votes
1 answer

Android - Show fragment on resume

I currently have a navigation drawer, which has a few fragments (Home, Help, About) in my activity. On startup it opens up Home. The issue i'm having is that when i go to another fragment such as Help and then proceed to put the phone to sleep and…
3
votes
2 answers

State of nested Fragments is lost when re-attached to their fragment container in bottom tab navigation

I am working on an app that has the following UI structure: One Activity, called FoodActivity This Activity implements bottom navigation. Hence, can show three categories of food: fruit, meat and fish The Activity has a big Fragment container,…
3
votes
0 answers

Android Fragment java.lang.IllegalStateException: No host

I do a lot of search about this problem but no answer helps me. I saw a same question in here but it can not help, so I post my question with the hope that any guy can help me. It's serious to me. I have an Activity(called activity A, it's…
ThaiPD
  • 3,503
  • 3
  • 30
  • 48
3
votes
1 answer

How do I stop overlapping fragments on an orientation change?

I have an app that uses fragments to display data. The main activity shown below controls the fragments with a recyclerview inside it and when I do an orientation change it I have, what looks like, one recyclerview overlapping another. On every…
3
votes
2 answers

Add several back stack entries within single fragment transaction

I need to display a Fragment with 2 fragments before it being added into back stack. However addToBackStack method belongs to FragmentTransaction so I cannot add all three of them in the single FragmentTransaction cause all three of them will be…
Lingviston
  • 5,479
  • 5
  • 35
  • 67
3
votes
0 answers

Best Practice/usual way to switch between 2 fragments in FrameLayout

I working on a app whitch has 1 activity with 2 buttons (Map and Listview). By clicking on the buttons the fragment into the FrameLayout needs to change from a listview to a mapview (or from map to listview). I got this working and the fragments are…
3
votes
1 answer

Restoring state when coming back to nested viewpager causes crash

I have a button that adds the ParentFragment. Inside theres a Viewpager containing two ListFragments. The first time adding the ParentFragment, everything works fine, except when I press back and add the ParentFragment again. The ParentFragment gets…
3
votes
0 answers

TabBar Activity with Fragments - Fragment lifecycle different between swipe and tab

I've recently made a refactoring of my code in order to use the Toolbar, TabLayout and TabLayout.Tab objects following this tutorial. The main structure (swipe and tab) works perfectly, as I'm able to move between them as I was expecting. When…
3
votes
3 answers