1 /* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 * in compliance with the License. You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software distributed under the License 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 * or implied. See the License for the specific language governing permissions and limitations under 12 * the License. 13 */ 14 package com.example.android.leanback; 15 16 import android.app.Activity; 17 import android.content.Intent; 18 import android.os.Bundle; 19 import android.support.v17.leanback.R; 20 import android.support.v17.leanback.widget.BrowseFrameLayout; 21 import android.support.v17.leanback.widget.TitleHelper; 22 import android.support.v17.leanback.widget.TitleView; 23 import android.view.View; 24 25 public class RowsActivity extends Activity 26 { 27 private RowsFragment mRowsFragment; 28 private TitleHelper mTitleHelper; 29 30 /** Called when the activity is first created. */ 31 @Override onCreate(Bundle savedInstanceState)32 public void onCreate(Bundle savedInstanceState) { 33 super.onCreate(savedInstanceState); 34 setContentView(R.layout.rows); 35 36 mRowsFragment = (RowsFragment) getFragmentManager().findFragmentById( 37 R.id.main_rows_fragment); 38 39 setupTitleFragment(); 40 } 41 setupTitleFragment()42 private void setupTitleFragment() { 43 TitleView titleView = (TitleView) findViewById(R.id.title); 44 titleView.setTitle("RowsFragment"); 45 titleView.setOnSearchClickedListener(new View.OnClickListener() { 46 @Override 47 public void onClick(View view) { 48 Intent intent = new Intent(RowsActivity.this, SearchActivity.class); 49 startActivity(intent); 50 } 51 }); 52 53 BrowseFrameLayout frameLayout = (BrowseFrameLayout) findViewById(R.id.rows_frame); 54 mTitleHelper = new TitleHelper(frameLayout, titleView); 55 frameLayout.setOnFocusSearchListener(mTitleHelper.getOnFocusSearchListener()); 56 mRowsFragment.setTitleHelper(mTitleHelper); 57 } 58 } 59