Questions tagged [android-nested-fragment]

Nested android fragments represent fragments which are embedded in other fragments.

Nested fragments were introduced in the Android SDK starting with API level 4.2. They are also available on lower API versions through the support compatibility package.

By using getChildFragmentManager()(method of the Fragment class), a fragment can have the behavior of a FragmentActivity. The nested fragments workflow closely follows the one of a normal fragment(which is embedded at in an Activity). For more information about fragments, see the Google Documentaton.

When asking questions about nested fragments one should always add the tag, optionally the could also be added.

281 questions
170
votes
13 answers

Fragment Inside Fragment

I need help regarding working on fragment inside fragment, actually I am facing a problem on pressing back button. Application Main screen has buttons and pressing on each button view replace with new fragment(and that fragment contain inside…
Ijaz Ahmed
  • 2,330
  • 4
  • 19
  • 27
149
votes
6 answers

Fragments within Fragments

I'm wondering if this is actually a bug in the Android API: I have a setup like so: ┌----┬---------┐ | | | | 1 | 2 | | |┌-------┐| | || || | || 3 || └----┴┴-------┴┘ Is a menu which loads fragment #2 (A search…
Graeme
  • 25,714
  • 24
  • 124
  • 186
115
votes
5 answers

Best practice for nested fragments in Android 4.0, 4.1 (<4.2) without using the support library

I'm writing an app for 4.0 and 4.1 tablets, for which I do not want to use the support libraries (if not needed) but the 4.x api only therefore. So my target platform is very well defined as: >= 4.0 and <= 4.1 The app has a multi-pane layout (two…
115
votes
18 answers

Android 4.2: back stack behaviour with nested fragments

With Android 4.2, the support library got support for nested fragments see here. I've played around with it and found an interesting behaviour / bug regarding back stack and getChildFragmentManager(). When using getChildFragmentManager() and…
AZ13
  • 14,397
  • 5
  • 35
  • 31
112
votes
14 answers

Getting the error "Java.lang.IllegalStateException Activity has been destroyed" when using tabs with ViewPager

I have an application that consists of using ActionBarSherlock in tab mode.I have 5 tabs and the content of each tab is handled using fragments. For tab2 though, I have a fragment the xml file of which holds a ViewPager element which in turn has…
103
votes
15 answers

Fragment in ViewPager using FragmentPagerAdapter is blank the second time it is viewed

I have a fragment interface with tabs along the bottom which open different fragments in the main view. I have one particular fragment which is a list of items. If the user selects one of the items in this list, another fragment opens which…
102
votes
16 answers

Nested fragments disappear during transition animation

Here's the scenario: Activity contains fragment A, which in turn uses getChildFragmentManager() to add fragments A1 and A2 in its onCreate like so: getChildFragmentManager() .beginTransaction() .replace(R.id.fragmentOneHolder, new FragmentA1()) …
80
votes
7 answers

onActivityResult() not called in new nested fragment API

I have been using the new nested fragment API that Android includes in the support library. The problem that I am facing with nested fragments is that, if a nested fragment (that is, a fragment that has been added to another fragment via the…
58
votes
8 answers

Sending data from nested fragments to parent fragment

I have a Fragment FR1 that contains several Nested Fragments; FRa, FRb, FRc. These Nested Fragments are changed by pressing Buttons on FR1's layout. Each of the Nested Fragments have several input fields within them; which include things like…
56
votes
6 answers

How to set a ViewPager inside a Fragment

I need to place a ViewPager inside of a fragment, but I have two fragments, Fragment 1 is my MENU, and Fragment 2 I want to use as a ViewPagerIndicator. But a fragment can't have another fragment... what do I need to do for that?
56
votes
4 answers

How to add a Fragment inside a ViewPager using Nested Fragment (Android 4.2)

I have a ViewPager with three Fragments, each one shows a List (or Grid). In the new Android API level 17 (Jelly Bean 4.2), one of the features is Nested Fragments. The new functionality description says: if you use ViewPager to create fragments…
55
votes
9 answers

Display fragment viewpager within a fragment

I have a fragment which contains a ViewPager. The ViewPager is associated with an adapter that contains a set of fragments. Upon loading the parent fragment, I am met with an IllegalStateException with the message: java.lang.IllegalStateException:…
53
votes
3 answers

ViewPager in TabFragment is not loading a second time

I'm trying to make an app that has a ViewPager in a Fragment that is part of a TabHost. Everything works out fine. I have my tabbar, I can switch tabs. When I switch to the tab with the ViewPager, all is shown correctly. However, as soon as I leave…
44
votes
9 answers

ViewPager inside ViewPager

I would like to create a ViewPager (with three items) where each of its view is another ViewPager (with two items). User then swipe items like this: ViewPager1[0] ViewPager2[0] ViewPager1[0] ViewPager2[1] ViewPager1[1] ViewPager2[0] ViewPager1[1]…
39
votes
1 answer

ViewPager + FragmentPagerAdapter inside a DialogFragment gets "IllegalArgumentException:No view found..."

I am trying to show a FragmentDialog ( created and shown as a dialog NOT added as content in a view hierarchy) where there is a ViewPager whose content is given by a FragmentPagerAdapter (provides Fragments consisting of an image). The code works…
1
2 3
18 19