diff --git a/samples/ApiDemos/src/com/example/android/apis/app/FragmentHideShow.java b/samples/ApiDemos/src/com/example/android/apis/app/FragmentHideShow.java index e5e259968..3e9619de4 100644 --- a/samples/ApiDemos/src/com/example/android/apis/app/FragmentHideShow.java +++ b/samples/ApiDemos/src/com/example/android/apis/app/FragmentHideShow.java @@ -43,8 +43,14 @@ public class FragmentHideShow extends Activity { // The content view embeds two fragments; now retrieve them and attach // their "hide" button. FragmentManager fm = getFragmentManager(); - addShowHideListener(R.id.frag1hide, fm.findFragmentById(R.id.fragment1)); - addShowHideListener(R.id.frag2hide, fm.findFragmentById(R.id.fragment2)); + Fragment fragment1 = fm.findFragmentById(R.id.fragment1); + addShowHideListener(R.id.frag1hide, fragment1); + final Button button1 = (Button)findViewById(R.id.frag1hide); + button1.setText(fragment1.isHidden() ? "Show" : "Hide"); + Fragment fragment2 = fm.findFragmentById(R.id.fragment2); + addShowHideListener(R.id.frag2hide, fragment2); + final Button button2 = (Button)findViewById(R.id.frag2hide); + button2.setText(fragment2.isHidden() ? "Show" : "Hide"); } void addShowHideListener(int buttonId, final Fragment fragment) { diff --git a/samples/Support4Demos/src/com/example/android/supportv4/app/FragmentHideShowSupport.java b/samples/Support4Demos/src/com/example/android/supportv4/app/FragmentHideShowSupport.java index e0fcbdb82..34415062c 100644 --- a/samples/Support4Demos/src/com/example/android/supportv4/app/FragmentHideShowSupport.java +++ b/samples/Support4Demos/src/com/example/android/supportv4/app/FragmentHideShowSupport.java @@ -44,8 +44,14 @@ public class FragmentHideShowSupport extends FragmentActivity { // The content view embeds two fragments; now retrieve them and attach // their "hide" button. FragmentManager fm = getSupportFragmentManager(); - addShowHideListener(R.id.frag1hide, fm.findFragmentById(R.id.fragment1)); - addShowHideListener(R.id.frag2hide, fm.findFragmentById(R.id.fragment2)); + Fragment fragment1 = fm.findFragmentById(R.id.fragment1); + addShowHideListener(R.id.frag1hide, fragment1); + final Button button1 = (Button)findViewById(R.id.frag1hide); + button1.setText(fragment1.isHidden() ? "Show" : "Hide"); + Fragment fragment2 = fm.findFragmentById(R.id.fragment2); + addShowHideListener(R.id.frag2hide, fragment2); + final Button button2 = (Button)findViewById(R.id.frag2hide); + button2.setText(fragment2.isHidden() ? "Show" : "Hide"); } void addShowHideListener(int buttonId, final Fragment fragment) {