android-nested-fragment

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

心已入冬 提交于 2019-11-29 00:22:30
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 some fragment pages. When I initially start the application the application, I am able to switch between tabs no problem but when I press on tab2 for the second time I get the error mentioned above. The main activity is as follows: public class MainActivity extends SherlockFragmentActivity { @Override protected void onCreate(Bundle savedInstanceState)

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

爷,独闯天下 提交于 2019-11-28 23:26:52
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 create a DialogFragment and show it. public final class OverviewFragment extends Fragment { @Override

Nested Fragments and The Back Stack

∥☆過路亽.° 提交于 2019-11-28 20:36:25
Does the Back Stack support interaction with nested Fragments in Android? If it does, what am I doing wrong? In my implementation, the back button is completely ignoring the fact that I added this transaction to the back stack. I'm hoping it is not because of an issue with nested fragments and just me doing something incorrectly. The following code is inside of one of my fragments and is used to swap a new fragment with whatever nested fragment is currently showing: MyFragment fragment = new MyFragment(); FragmentTransaction ft = getChildFragmentManager().beginTransaction(); ft

ViewPager in TabFragment not loading second time

狂风中的少年 提交于 2019-11-28 16:49:35
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. But as soon as I leave this tab with the ViewPager and return this tab, my content is not shown. If I scroll to the side twice i do see my next image. And if I go back two times I also see the images are loaded (probably the offscreenloaded) See that my TabFragment is being reinstantiated when i return to it but the fragments in the ViewPager aren't. I've included a screen

getChildFragmentManager() on programmatically (dynamically) added Fragments?

跟風遠走 提交于 2019-11-28 15:59:52
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 want to keep this hierarchy: MainActivity -> OuterFrag -> InnerFrag . So MainActivity can always call

IllegalStateException Fragment already added - Android

淺唱寂寞╮ 提交于 2019-11-28 14:36:19
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.news_list_fragment)); getActivity().getSupportFragmentManager().beginTransaction() .replace(R.id.frame

fragments in viewpager, no view found error

こ雲淡風輕ζ 提交于 2019-11-28 04:06:03
问题 I have an activity holding a fragment, in this fragment there is a button , when it is clicked, a dialog is popped out. In this dialog, there is a Viewpager, which holds some fragments to display. Here are the code and the error, please spare your valuable time to show me where I am wrong. I much appreciate your help. MainActivity.class import android.os.Bundle; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app

onCreateView() of nested fragment is not called

…衆ロ難τιáo~ 提交于 2019-11-28 01:38:22
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 to sort this out. The example flow is as below:-- MainActivity hosts a fragment(MessageFragment) and

ActionBarSherlock with ViewPager not calling ViewPager fragments lifecycle methods when going to and returning from backstack

不想你离开。 提交于 2019-11-28 01:29:02
问题 I have an application that uses ActionBarSherlock and inside the main fragment I have a ViewPager which uses several fragments to display different objects of a list. Main Fragment: public class CollectionDemoFragment extends SherlockFragment { DemoCollectionPagerAdapter mDemoCollectionPagerAdapter; ViewPager mViewPager; public CollectionDemoFragment() { setTitle(R.string.title); setHasOptionsMenu(true); } public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); }

Nested fragments transitioning incorrectly

 ̄綄美尐妖づ 提交于 2019-11-27 17:26:58
问题 Hello good programmers of stack overflow! I've spent a good week with this problem and am now very desperate for a solution. The scenario I'm using android.app.Fragment's not to be confused with the support fragments. I have 6 child fragments named: FragmentOne FragmentTwo FragmentThree FragmentA FragmentB FragmentC I have 2 parent fragments named: FragmentNumeric FragmentAlpha I have 1 activity named: MainActivity They behave in the following: Child fragments are fragments that only show a