android-nested-fragment

DialogFrag#show() from a Fragment throwing “IllegalStateException: Can not perform this action after onSaveInstanceState”

守給你的承諾、 提交于 2019-11-27 14:47:37
问题 Just to be clear, I have read the dozen top SO questions on "IllegalStateException: Can not perform this action after onSaveInstanceState" and I have read Alex Lockwood's blog post on the issue http://www.androiddesignpatterns.com/2013/08/fragment-transaction-commit-state-loss.html So I'm not asking this blindly. I have a very simple use case case that doesn't involve AsyncTask or any background processing. I have a Fragment that contains a button. On the onClickListener for the button, I

getParentFragment returning null

回眸只為那壹抹淺笑 提交于 2019-11-27 14:35:13
I have a Fragment that has a FrameLayout . This first fragment (A) loads inside its Framelayout another fragment (B). When I call getParentFragment from inner fragment (B), I get null . How should this method be used properly? Eurig Jones getParentFragment() was introduced in API level 17 (Android 4.2). Android 4.2 introduced the idea of nested fragments (fragments containing other fragments). Calling this results in null if the fragment has a parent which is an Activity. Have a look at this . If you are using support library then you can use getParent(), may be you need to use

getChildFragmentManager() on programmatically (dynamically) added Fragments?

白昼怎懂夜的黑 提交于 2019-11-27 09:29:32
问题 How to use (or "Can we use") getChildFragmentManager() on programmatically (dynamically) added Fragment s? Here is my example. I have one MainActivity , one OuterFrag , and one InnerFrag . I will add the OuterFrag to MainActivity dynamically by the FragmentManager . And also, I will add the InnerFrag to the OuterFrag also dynamically by the FragmentManager . But I want to add InnerFrag exactly as a child of the OuterFrag , not replacing OuterFrag and be the new child of the MainActivity . I

IllegalStateException Fragment already added - Android

做~自己de王妃 提交于 2019-11-27 08:38:30
问题 I am adding fragment like bellow : @OnClick(R.id.lnNews) void newsList() { String tagName = returnStatusFragment(getString(R.string.news_list_fragment)); if (!TextUtils.isEmpty(tagName) && tagName.equals(getString(R.string.news_list_fragment))) { frameWorkTableFragment.setVisibility(View.VISIBLE); if (getActivity() != null) { android.support.v4.app.FragmentManager fragmentManager = getActivity().getSupportFragmentManager(); Fragment news = fragmentManager.findFragmentByTag(getString(R.string

ViewPager inside ViewPager

限于喜欢 提交于 2019-11-27 02:43:53
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? override canScroll in the parent ViewPager: @Override protected boolean canScroll(View v, boolean checkV, int dx, int x, int y) { if(v != this && v instanceof ViewPager) { return true; } return super.canScroll(v, checkV, dx, x, y); } Try this: public

Nested fragments disappear during transition animation

為{幸葍}努か 提交于 2019-11-27 02:36:47
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, anim1, anim2) .replace(R.id.fragmentHolder, new FragmentB()) .addToBackStack(null) .commit() During the

Android 4.2: back stack behaviour with nested fragments

旧巷老猫 提交于 2019-11-27 02:30:43
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 returns to the previous fragment. For me, this behaviour is unexpected. By pressing the back button on my

onCreateView() of nested fragment is not called

穿精又带淫゛_ 提交于 2019-11-26 23:33:51
问题 I have been going through nested fragments documentation, best practices and all possible links here in StackOverflow. I have seen suggestions to avoid using fragment tag in layout files and instead add them via transaction for seamless transitions. Before implementing it in my app, I tried a simple example and I found some unexpected behavior, child fragments onCreateView() is not getting called. I assume that , I am missing something in my understanding, so I am looking for some advice/help

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

大兔子大兔子 提交于 2019-11-26 21:22:23
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 contains a viewpager which scrolls horizontally between all of the items in the list in the previous fragment. This works great. The viewpager uses a FragmentPagerAdapter to display the items. The problem comes when the user selects an item in the list, views it, then hits the button on the tab bar to go back to the list, then selects another item. The

How to set a ViewPager inside a Fragment

ぐ巨炮叔叔 提交于 2019-11-26 19:48:54
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? Ryan S 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 public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view,