android-nested-fragment

onActivityResult() not called in new nested fragment API

烂漫一生 提交于 2019-11-26 17:15:32
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 FragmentManager returned by getChildFragmentManager() ) calls startActivityForResult() , the nested fragment's onActivityResult() method is not called. However, both the parent fragment's onActivityResult() and activity's onActivityResult() do get called. I don't know if I am missing something about nested fragments, but I did not expect the described

Android: Can you nest Fragments?

前提是你 提交于 2019-11-26 16:34:05
Is it possible to stick a Fragment in the layout of another Fragment ? Has anyone tried this? Dan Elkayam Finally! the android 4.2 update comes with default support for nested fragments, also compatible: Official NestedFragments . What's more, the support of the nested Fragments in announced in the latest 11th revision of the v4 support library ! hackbod No, fragments are currently NOT in a hierarchy. Trying to have one fragment embedded in another can lead to problems, often subtle. Edit: As of ACLv11 this is only needed if you replace(...) ViewPagers dynamically. Yes you can, but there are

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

笑着哭i 提交于 2019-11-26 15:38:39
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 fragments, one small on the left, one content fragment on the right) and an action bar with tabs. Similar to this: Clicking a tab on the action bar changes the 'outer' fragment, and the inner fragment then is a fragment with two nested fragments (1. small left list fragment, 2. wide content fragment). I am now wondering what's the best practice to

Display fragment viewpager within a fragment

主宰稳场 提交于 2019-11-26 12:46:48
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: Recursive entry to executePendingTransactions . Some research has led me to the conclusion that the system is unable display fragments within another fragment, HOWEVER there seems to be some indication that it is possible to do exactly this with the use of a ViewPager ( A bug in ViewPager using it with other fragment ). In fact, if I add a button to

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

血红的双手。 提交于 2019-11-26 12:41:35
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 that swipe left and right and consume a majority of the screen space, you can now insert fragments into each fragment page. So, if I understand right, now I can create a ViewPager with Fragments (with a button inside for example) inside, and when user press the button show another Fragment without loose the ViewPager using this new feature. I've

ViewPager inside ViewPager

China☆狼群 提交于 2019-11-26 12:34:59
问题 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] ViewPager2[1] ViewPager1[2] ViewPager2[0] ViewPager1[2] ViewPager2[1] How would that be possible? 回答1: override canScroll in the parent ViewPager: @Override protected boolean canScroll(View v, boolean checkV, int dx, int x, int y) { if(v != this && v

Nested fragments disappear during transition animation

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-26 10:08:12
问题 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()) .replace(R.id.fragmentTwoHolder, new FragmentA2()) .commit() So far, so good, everything is running as expected. We then run the following transaction in the Activity: getSupportFragmentManager() .beginTransaction() .setCustomAnimations(anim1, anim2,

Android 4.2: back stack behaviour with nested fragments

不打扰是莪最后的温柔 提交于 2019-11-26 10:07:53
问题 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 addToBackStack(String name), by pressing the back button the system does not run down the back stack to the previous fragment. On the other hand, when using getFragmentManager() and addToBackStack(String name), by pressing the back button the system

onActivityResult() not called in new nested fragment API

我与影子孤独终老i 提交于 2019-11-26 08:53:24
问题 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 FragmentManager returned by getChildFragmentManager() ) calls startActivityForResult() , the nested fragment\'s onActivityResult() method is not called. However, both the parent fragment\'s onActivityResult() and activity\'s onActivityResult() do get

How to set a ViewPager inside a Fragment

谁说我不能喝 提交于 2019-11-26 07:27:24
问题 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? 回答1: Starting in Android 4.2, there are nested fragments.http://developer.android.com/about/versions/android-4.2.html#NestedFragments The support library now also includes support for this for older Android versions. So you can do something like this: @Override