Skip to content

Commit

Permalink
Avoid fragment being created twice
Browse files Browse the repository at this point in the history
Avoid fragment being created twice. Proposal to solve jfeinstein10#336
  • Loading branch information
yccheok committed Mar 20, 2013
1 parent 29d40b6 commit 1c1d8df
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions example/src/com/slidingmenu/example/BaseActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,14 @@ public void onCreate(Bundle savedInstanceState) {

// set the Behind View
setBehindContentView(R.layout.menu_frame);
FragmentTransaction t = this.getSupportFragmentManager().beginTransaction();
mFrag = new SampleListFragment();
t.replace(R.id.menu_frame, mFrag);
t.commit();
if (savedInstanceState == null) {
FragmentTransaction t = this.getSupportFragmentManager().beginTransaction();
mFrag = new SampleListFragment();
t.replace(R.id.menu_frame, mFrag);
t.commit();
} else {
mFrag = (ListFragment)this.getSupportFragmentManager().findFragmentById(R.id.menu_frame);
}

// customize the SlidingMenu
SlidingMenu sm = getSlidingMenu();
Expand Down

0 comments on commit 1c1d8df

Please sign in to comment.