diff options
Diffstat (limited to 'Android/04-TheFragmentClass/FragmentsLab/src/course/labs/fragmentslab/MainActivity.java')
-rw-r--r-- | Android/04-TheFragmentClass/FragmentsLab/src/course/labs/fragmentslab/MainActivity.java | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/Android/04-TheFragmentClass/FragmentsLab/src/course/labs/fragmentslab/MainActivity.java b/Android/04-TheFragmentClass/FragmentsLab/src/course/labs/fragmentslab/MainActivity.java index 6309bae..9fa845e 100644 --- a/Android/04-TheFragmentClass/FragmentsLab/src/course/labs/fragmentslab/MainActivity.java +++ b/Android/04-TheFragmentClass/FragmentsLab/src/course/labs/fragmentslab/MainActivity.java @@ -21,7 +21,9 @@ FriendsFragment.SelectionListener { // and add it to the Activity if (!isInTwoPaneMode()) { mFriendsFragment = new FriendsFragment(); - //TODO 1 - add the FriendsFragment to the fragment_container + FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction(); + fragmentTransaction.add(R.id.fragment_container, mFriendsFragment); + fragmentTransaction.commit(); } else { // Otherwise, save a reference to the FeedFragment for later use mFeedFragment = (FeedFragment) getFragmentManager().findFragmentById(R.id.feed_frag); @@ -42,8 +44,10 @@ FriendsFragment.SelectionListener { mFeedFragment = new FeedFragment(); // If in single-pane mode, replace single visible Fragment if (!isInTwoPaneMode()) { - //TODO 2 - replace the fragment_container with the FeedFragment - // execute transaction now + FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction(); + fragmentTransaction.replace(R.id.fragment_container, mFeedFragment); + fragmentTransaction.addToBackStack(null); + fragmentTransaction.commit(); getFragmentManager().executePendingTransactions(); } // Update Twitter feed display on FriendFragment |