1 /* 2 * Copyright (C) 2015 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License 15 */ 16 17 package android.support.v17.preference; 18 19 import android.os.Build; 20 import android.os.Bundle; 21 import android.view.LayoutInflater; 22 import android.view.View; 23 import android.view.ViewGroup; 24 import android.widget.TextView; 25 26 /** 27 * This fragment provides a fully decorated leanback-style preference fragment, including a 28 * list background and header. 29 */ 30 public abstract class LeanbackPreferenceFragment extends BaseLeanbackPreferenceFragment { 31 LeanbackPreferenceFragment()32 public LeanbackPreferenceFragment() { 33 if (Build.VERSION.SDK_INT >= 21) { 34 LeanbackPreferenceFragmentTransitionHelperApi21.addTransitions(this); 35 } 36 } 37 38 @Override onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)39 public View onCreateView(LayoutInflater inflater, ViewGroup container, 40 Bundle savedInstanceState) { 41 final View view = inflater.inflate(R.layout.leanback_preference_fragment, container, false); 42 final ViewGroup innerContainer = (ViewGroup) view.findViewById(R.id.main_frame); 43 final View innerView = super.onCreateView(inflater, innerContainer, savedInstanceState); 44 if (innerView != null) { 45 innerContainer.addView(innerView); 46 } 47 return view; 48 } 49 50 @Override onViewCreated(View view, Bundle savedInstanceState)51 public void onViewCreated(View view, Bundle savedInstanceState) { 52 super.onViewCreated(view, savedInstanceState); 53 final TextView decorTitle = (TextView) view.findViewById(R.id.decor_title); 54 decorTitle.setText(getPreferenceScreen().getTitle()); 55 } 56 } 57