Last active
September 2, 2016 14:54
-
-
Save patrickmclaren/95a5617ebd3418acb0ca to your computer and use it in GitHub Desktop.
Revisions
-
patrickmclaren revised this gist
Sep 2, 2016 . 1 changed file with 10 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,13 @@ package com.patrickmclaren.examples.asyncfragments; import android.app.Activity; import android.app.FragmentManager; import android.app.FragmentTransaction; import android.content.res.Configuration; import android.os.Bundle; public class FragmentActivity extends Activity { private ExampleFragment mFragment; @Override -
patrickmclaren created this gist
Mar 19, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ public FragmentActivity extends Activity { private ExampleFragment mFragment; @Override public void onCreate(Bundle savedInstanceState) { super(savedInstanceState) } public void addFragment() { FragmentManager fm = getSupportFragmentManager(); mFragment = (ExampleFragment) fm.findFragmentByTag(ExampleFragment.TAG); if (mFragment == null) { FragmentTransaction ft = fm.beginTransaction(); mFragment = new ExampleFragment(); ft.add(R.id.container, mFragment, ExampleFragment.TAG); try { ft.commit(); } catch(IllegalStateException e) { // Activity may be destroyed, you can't complete this transaction mFragment = null; } } else { // Fragment already added if (mFragment.isInLayout()) { // Fragment in View hierarchy } } } }