diff options
author | Dake Gu <dake@google.com> | 2015-10-28 15:42:26 -0700 |
---|---|---|
committer | Dake Gu <dake@google.com> | 2015-10-29 11:57:43 -0700 |
commit | caaf7b076e0b848c74880e12f23493d4a1d16984 (patch) | |
tree | 85df2d4e2abbe906e2c3333e4324b0dc7cad72b6 | |
parent | bea9cef30218cd91abbf46cb98f4a3b4204f00a5 (diff) | |
download | android_development-caaf7b076e0b848c74880e12f23493d4a1d16984.tar.gz android_development-caaf7b076e0b848c74880e12f23493d4a1d16984.tar.bz2 android_development-caaf7b076e0b848c74880e12f23493d4a1d16984.zip |
Dont use R.id.content to host GuidedStepFragment
Added example of set action not focusable
Bug 25352427
Change-Id: Ie9aed8c52d7639c3a39938117be94a65cf2005eb
7 files changed, 48 insertions, 12 deletions
diff --git a/samples/SupportLeanbackDemos/res/layout/browse.xml b/samples/SupportLeanbackDemos/res/layout/browse.xml index 4d46233ce..1642c4457 100644 --- a/samples/SupportLeanbackDemos/res/layout/browse.xml +++ b/samples/SupportLeanbackDemos/res/layout/browse.xml @@ -32,4 +32,9 @@ android:layout_width="match_parent" android:layout_height="match_parent" /> + <!-- container for hosting GuidedStepFragment --> + <FrameLayout android:id="@+id/lb_guidedstep_host" + android:layout_width="match_parent" + android:layout_height="match_parent" /> + </FrameLayout> diff --git a/samples/SupportLeanbackDemos/res/layout/browse_support.xml b/samples/SupportLeanbackDemos/res/layout/browse_support.xml index 34cdffea3..b0c72a48b 100644 --- a/samples/SupportLeanbackDemos/res/layout/browse_support.xml +++ b/samples/SupportLeanbackDemos/res/layout/browse_support.xml @@ -34,4 +34,9 @@ android:layout_width="match_parent" android:layout_height="match_parent" /> + <!-- container for hosting GuidedStepFragment --> + <FrameLayout android:id="@+id/lb_guidedstep_host" + android:layout_width="match_parent" + android:layout_height="match_parent" /> + </FrameLayout> diff --git a/samples/SupportLeanbackDemos/res/layout/guided_step_activity.xml b/samples/SupportLeanbackDemos/res/layout/guided_step_activity.xml new file mode 100644 index 000000000..a1de2135c --- /dev/null +++ b/samples/SupportLeanbackDemos/res/layout/guided_step_activity.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2014 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<!-- container for hosting GuidedStepFragment --> +<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/lb_guidedstep_host" + android:layout_width="match_parent" + android:layout_height="match_parent" /> diff --git a/samples/SupportLeanbackDemos/src/com/example/android/leanback/BrowseFragment.java b/samples/SupportLeanbackDemos/src/com/example/android/leanback/BrowseFragment.java index f4c8044b0..6797dbe0c 100644 --- a/samples/SupportLeanbackDemos/src/com/example/android/leanback/BrowseFragment.java +++ b/samples/SupportLeanbackDemos/src/com/example/android/leanback/BrowseFragment.java @@ -136,7 +136,7 @@ public class BrowseFragment extends android.support.v17.leanback.app.BrowseFragm if (((PhotoItem) item).getImageResourceId() == R.drawable.gallery_photo_6) { GuidedStepFragment.add(getFragmentManager(), new GuidedStepActivity.FirstStepFragment(), - android.R.id.content); + R.id.lb_guidedstep_host); return; } else if ( ((PhotoItem) item).getImageResourceId() == R.drawable.gallery_photo_8) { intent = new Intent(getActivity(), BrowseActivity.class); diff --git a/samples/SupportLeanbackDemos/src/com/example/android/leanback/BrowseSupportFragment.java b/samples/SupportLeanbackDemos/src/com/example/android/leanback/BrowseSupportFragment.java index 7af875543..29851b335 100644 --- a/samples/SupportLeanbackDemos/src/com/example/android/leanback/BrowseSupportFragment.java +++ b/samples/SupportLeanbackDemos/src/com/example/android/leanback/BrowseSupportFragment.java @@ -138,7 +138,7 @@ public class BrowseSupportFragment extends android.support.v17.leanback.app.Brow if (((PhotoItem) item).getImageResourceId() == R.drawable.gallery_photo_6) { GuidedStepSupportFragment.add(getFragmentManager(), new GuidedStepSupportActivity.FirstStepFragment(), - android.R.id.content); + R.id.lb_guidedstep_host); return; } else if ( ((PhotoItem) item).getImageResourceId() == R.drawable.gallery_photo_8) { intent = new Intent(getActivity(), BrowseSupportActivity.class); diff --git a/samples/SupportLeanbackDemos/src/com/example/android/leanback/GuidedStepActivity.java b/samples/SupportLeanbackDemos/src/com/example/android/leanback/GuidedStepActivity.java index 52ed739b0..46f1ba9cd 100644 --- a/samples/SupportLeanbackDemos/src/com/example/android/leanback/GuidedStepActivity.java +++ b/samples/SupportLeanbackDemos/src/com/example/android/leanback/GuidedStepActivity.java @@ -61,7 +61,8 @@ public class GuidedStepActivity extends Activity { protected void onCreate(Bundle savedInstanceState) { Log.v(TAG, "onCreate"); super.onCreate(savedInstanceState); - GuidedStepFragment.addAsRoot(this, new FirstStepFragment(), android.R.id.content); + setContentView(R.layout.guided_step_activity); + GuidedStepFragment.addAsRoot(this, new FirstStepFragment(), R.id.lb_guidedstep_host); } @Override @@ -174,7 +175,7 @@ public class GuidedStepActivity extends Activity { public void onGuidedActionClicked(GuidedAction action) { FragmentManager fm = getFragmentManager(); if (action.getId() == GuidedAction.ACTION_ID_CONTINUE) { - GuidedStepFragment.add(fm, new SecondStepFragment(), android.R.id.content); + GuidedStepFragment.add(fm, new SecondStepFragment(), R.id.lb_guidedstep_host); } else if (action.getId() == GuidedAction.ACTION_ID_CANCEL){ finishGuidedStepFragments(); } @@ -215,7 +216,7 @@ public class GuidedStepActivity extends Activity { public void onGuidedActionClicked(GuidedAction action) { if (action.getId() == GuidedAction.ACTION_ID_CONTINUE) { FragmentManager fm = getFragmentManager(); - GuidedStepFragment.add(fm, new ThirdStepFragment()); + GuidedStepFragment.add(fm, new ThirdStepFragment(), R.id.lb_guidedstep_host); } } @@ -301,7 +302,8 @@ public class GuidedStepActivity extends Activity { .description(desc) .multilineDescription(true) .infoOnly(true) - .enabled(false) + .enabled(true) + .focusable(false) .build()); for (int i = 0; i < OPTION_NAMES.length; i++) { addCheckedAction(actions, OPTION_DRAWABLES[i], getActivity(), OPTION_NAMES[i], @@ -322,7 +324,7 @@ public class GuidedStepActivity extends Activity { Bundle arguments = new Bundle(); arguments.putInt(FourthStepFragment.EXTRA_OPTION, mSelectedOption); f.setArguments(arguments); - GuidedStepFragment.add(fm, f, android.R.id.content); + GuidedStepFragment.add(fm, f, R.id.lb_guidedstep_host); } else { mSelectedOption = getSelectedActionPosition()-1; } diff --git a/samples/SupportLeanbackDemos/src/com/example/android/leanback/GuidedStepSupportActivity.java b/samples/SupportLeanbackDemos/src/com/example/android/leanback/GuidedStepSupportActivity.java index 7f3a33a84..8baeb6a82 100644 --- a/samples/SupportLeanbackDemos/src/com/example/android/leanback/GuidedStepSupportActivity.java +++ b/samples/SupportLeanbackDemos/src/com/example/android/leanback/GuidedStepSupportActivity.java @@ -63,7 +63,8 @@ public class GuidedStepSupportActivity extends FragmentActivity { protected void onCreate(Bundle savedInstanceState) { Log.v(TAG, "onCreate"); super.onCreate(savedInstanceState); - GuidedStepSupportFragment.addAsRoot(this, new FirstStepFragment(), android.R.id.content); + setContentView(R.layout.guided_step_activity); + GuidedStepSupportFragment.addAsRoot(this, new FirstStepFragment(), R.id.lb_guidedstep_host); } @Override @@ -176,7 +177,7 @@ public class GuidedStepSupportActivity extends FragmentActivity { public void onGuidedActionClicked(GuidedAction action) { FragmentManager fm = getFragmentManager(); if (action.getId() == GuidedAction.ACTION_ID_CONTINUE) { - GuidedStepSupportFragment.add(fm, new SecondStepFragment(), android.R.id.content); + GuidedStepSupportFragment.add(fm, new SecondStepFragment(), R.id.lb_guidedstep_host); } else if (action.getId() == GuidedAction.ACTION_ID_CANCEL){ finishGuidedStepSupportFragments(); } @@ -217,7 +218,7 @@ public class GuidedStepSupportActivity extends FragmentActivity { public void onGuidedActionClicked(GuidedAction action) { if (action.getId() == GuidedAction.ACTION_ID_CONTINUE) { FragmentManager fm = getFragmentManager(); - GuidedStepSupportFragment.add(fm, new ThirdStepFragment()); + GuidedStepSupportFragment.add(fm, new ThirdStepFragment(), R.id.lb_guidedstep_host); } } @@ -303,7 +304,8 @@ public class GuidedStepSupportActivity extends FragmentActivity { .description(desc) .multilineDescription(true) .infoOnly(true) - .enabled(false) + .enabled(true) + .focusable(false) .build()); for (int i = 0; i < OPTION_NAMES.length; i++) { addCheckedAction(actions, OPTION_DRAWABLES[i], getActivity(), OPTION_NAMES[i], @@ -324,7 +326,7 @@ public class GuidedStepSupportActivity extends FragmentActivity { Bundle arguments = new Bundle(); arguments.putInt(FourthStepFragment.EXTRA_OPTION, mSelectedOption); f.setArguments(arguments); - GuidedStepSupportFragment.add(fm, f, android.R.id.content); + GuidedStepSupportFragment.add(fm, f, R.id.lb_guidedstep_host); } else { mSelectedOption = getSelectedActionPosition()-1; } |