piggybank1974 Posted April 14, 2014 Share Posted April 14, 2014 what I'm trying to do is in portrait mode display a fragment, in landscape mode display two fragments side by side. it all seems to work fine until I rotate the emulator from landscape to portrait then the app crashes with this: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.fragmentapp/com.fragmentapp.MainActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x7f030002 it all works fine if I put the fragments in the XML but I'm trying to call them programically with this: @Override protected void onCreate(Bundle savedInstanceState) { FragmentTransaction mft = getFragmentManager().beginTransaction(); super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); FragmentOne mFragmentOne = new FragmentOne(); //getFragmentManager().beginTransaction().add(R.id.container, mFragmentOne).commit(); mft.add(R.id.leftfragment, mFragmentOne); if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { FragmentTwo mFragmentTwo = new FragmentTwo(); mft.add(R.id.rightfragment, mFragmentTwo); //getFragmentManager().beginTransaction().add(R.id.container, mFragmentTwo).commit(); } else { FrameLayout FragmentContainer = (FrameLayout) findViewById(R.id.rightfragment); if (FragmentContainer != null) { getFragmentManager().beginTransaction().remove(new FragmentTwo()).commit(); } } mft.addToBackStack(null); mft.commit(); } I do have fragmentone.xml in layout folder where I have fragmetone.xml/fragmenttwo.xml in layout-land folder if this helps?? any body got any ideas! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.