summaryrefslogtreecommitdiffstats
path: root/Android/04-TheFragmentClass
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-02-13 22:15:31 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2016-11-10 17:40:55 +0100
commit36280db96fe3e135b64e85365b346d387b5dba18 (patch)
tree2082389e3d7b99b2ab6659a3c55b7b17443df4fe /Android/04-TheFragmentClass
parentaa33f187990a0858de0252c96a695d984ba9b924 (diff)
downloadcoursera-36280db96fe3e135b64e85365b346d387b5dba18.zip
coursera-36280db96fe3e135b64e85365b346d387b5dba18.tar.gz
Android : 04-TheFragmentClass: implement
Diffstat (limited to 'Android/04-TheFragmentClass')
-rw-r--r--Android/04-TheFragmentClass/FragmentsLab/src/course/labs/fragmentslab/MainActivity.java10
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