diff --git a/samples/Support4Demos/res/layout/fragment_stack.xml b/samples/Support4Demos/res/layout/fragment_stack.xml
index 1d12496ac..0f0951fd6 100644
--- a/samples/Support4Demos/res/layout/fragment_stack.xml
+++ b/samples/Support4Demos/res/layout/fragment_stack.xml
@@ -28,11 +28,19 @@
android:layout_weight="1">
-
+ android:layout_weight="0" android:orientation="horizontal">
+
+
+
diff --git a/samples/Support4Demos/res/values/strings.xml b/samples/Support4Demos/res/values/strings.xml
index 8f70fd386..f8f4a4f63 100644
--- a/samples/Support4Demos/res/values/strings.xml
+++ b/samples/Support4Demos/res/values/strings.xml
@@ -77,6 +77,7 @@
Fragment/Receive Result
Fragment/Stack
+ Go home
New fragment
Fragment/Tabs
diff --git a/samples/Support4Demos/src/com/example/android/supportv4/app/FragmentStackSupport.java b/samples/Support4Demos/src/com/example/android/supportv4/app/FragmentStackSupport.java
index c4d05fa9f..337f2c120 100644
--- a/samples/Support4Demos/src/com/example/android/supportv4/app/FragmentStackSupport.java
+++ b/samples/Support4Demos/src/com/example/android/supportv4/app/FragmentStackSupport.java
@@ -20,6 +20,7 @@ import com.example.android.supportv4.R;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
+import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.os.Bundle;
@@ -45,6 +46,17 @@ public class FragmentStackSupport extends FragmentActivity {
addFragmentToStack();
}
});
+ button = (Button)findViewById(R.id.home);
+ button.setOnClickListener(new OnClickListener() {
+ public void onClick(View v) {
+ // If there is a back stack, pop it all.
+ FragmentManager fm = getSupportFragmentManager();
+ if (fm.getBackStackEntryCount() > 0) {
+ fm.popBackStack(fm.getBackStackEntryAt(0).getId(),
+ FragmentManager.POP_BACK_STACK_INCLUSIVE);
+ }
+ }
+ });
if (savedInstanceState == null) {
// Do first time initialization -- add initial fragment.