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
2
votes
2 answers

IndexOutOfBoundsException in FragmentManager when resuming activity

What's the Problem: I have a main activity which have total 7 fragments added to it when it is loaded : 2 drawer navigation fragments, 1 viewPager Main fragment and 4 viewpager child fragments. new fragments are added whenever there's a need. So two…
Pro Mode
  • 1,453
  • 17
  • 30
2
votes
1 answer

use FragmentManager in fragment?

im really in trouble here. I am trying to open a dialog fragment from a fragment, but i cannot get it to work import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; public class FragmentDiscover extends Fragment { …
2
votes
3 answers

NullPointerException: android.support.v4.app.FragmentHostCallback.getHandler() on a null object reference

I am facing following issue. Scenario: For the very first time when I signup thru app, I am able to see tabs and there content but when I logout and try to login for the same code for viewpager i get following exception: NullPointerException:…
MobDev
  • 464
  • 4
  • 14
2
votes
3 answers

Return from fragment C to fragment A pressing back button

I have a fragments, for example A -> B -> C. When I'm in the fragment C, and press the back button I need to get on a fragment A. That is, fragment B is not necessary to add to backStack. Here is the code which implements the transition between…
2
votes
0 answers

IllegalStateException: FragmentManager is already executing transactions - TabLayout in DrawerLayout

I'm trying to implement DrawerLayout and TabLayout in one activity, however I get this error: java.lang.IllegalStateException: FragmentManager is already executing transactions Here's the code for MainActivity.java // ... import…
2
votes
2 answers

FragmentTransaction hide() upon Activity recreation(config change/etc)

FragmentTransaction's hide() does not persist when Activity gets recreated upon config change(rotation, etc). It re-adds all fragments in the back-stack, so the fragments previously hidden becomes visible. Ex) Fragments A(hide), B(show), C(hide),…
2
votes
0 answers

ChildFragmentManager crashes with "No Host" when used with BottomSheetDialogFragment containing a viewPager of fragments

I'm trying to implement bottomSheet with a viewpager displaying fragments, as shown in the mockup image. The bottomSheetFragment which houses the viewpager uses a childFragmentManager to manage the viewpager fragments. Below is the…
2
votes
2 answers

getHandler() NullPointerException when calling popBackstackImmediate() on a FragmentManager

I have this sime line in my code: getChildFragmentManager().popBackstackImmediate(); It sometimes works, but often crashes. Here's the stacktrace: java.lang.NullPointerException: Attempt to invoke virtual method 'android.os.Handler…
Guy
  • 6,414
  • 19
  • 66
  • 136
2
votes
2 answers

FragmentStatePagerAdapter - getItem

I know there are several other posts on this topic, but I wanted to paste my code because I believe there may be an error in it that is causing my problem. My FragmentStatePagerAdapter is returning the wrong position, and I am not sure why. Here is…
Phil
  • 4,029
  • 9
  • 62
  • 107
2
votes
0 answers

ViewPager get invisible after coming from navigation drawer

I have been developing an app which contain navigation drawer on main page and on main page I have an framelayout in which I am displaying HomeFragment.java which contain viewPager. The problem is when I launch my application the HomeFragment.java…
2
votes
1 answer

Android: Changing "ViewPager" animation from Fragment to Fragment

I am having an application with few fragments. I am using ViewPager and I have an expectation of providing a different animation for ViewPager transactions. Below is my code. public class MainActivity extends FragmentActivity { private…
PeakGen
  • 21,894
  • 86
  • 261
  • 463
2
votes
1 answer

Android - Pop two or more fragments but don't the top

I have the following scenario: A(Bottom) -> B -> C -> D(Top) -back-> A A(Bottom) -> B -> C -back-> B -back-> A Once I'm on the top (D fragment) I want to pop B and C fragment. On this way when I press back from D I can to A. I want to avoid the…
Ricardo
  • 7,921
  • 14
  • 64
  • 111
2
votes
0 answers

Why inner fragments menu is persisted?

This question is about options menus inflated from Fragments into a Toolbar, via Fragment#setHasOptionsMenu(true). Let’s say we have an activity with 3 fragments: FragmentA FragmentB (with menu) FragmentC FragmentD (with menu) Fragments A, B…
natario
  • 24,954
  • 17
  • 88
  • 158
2
votes
1 answer

How can I do a fragmentTransaction in other class?

I want create a class whose funtion is only do a fragmentTransaction but I have an error. My class is the next: package net.elinformaticoenganchado.sergio.crossfighters.common; import android.support.v4.app.Fragment; import…
Sermanes
  • 496
  • 8
  • 22
2
votes
0 answers

onOptionsItemSelected is called for wrong fragment (different fragment from backstack)

I have an issue with onOptionsItemSelected event. My application consist of Activity, main fragment, multiple function fragments. Activity's FragmentManager contains only one Fragment (MainFragment). MainFragment's ChildFragmentManager contains up…