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 */ 14package com.example.android.leanback; 15 16import android.app.Activity; 17import android.content.Intent; 18import android.os.Bundle; 19import android.support.v17.leanback.widget.BrowseFrameLayout; 20import android.support.v17.leanback.widget.TitleHelper; 21import android.support.v17.leanback.widget.TitleView; 22import android.view.View; 23 24public class RowsActivity extends Activity 25{ 26 private RowsFragment mRowsFragment; 27 28 /** Called when the activity is first created. */ 29 @Override 30 public void onCreate(Bundle savedInstanceState) { 31 super.onCreate(savedInstanceState); 32 setContentView(R.layout.rows); 33 34 mRowsFragment = (RowsFragment) getFragmentManager().findFragmentById( 35 R.id.main_rows_fragment); 36 37 setupTitleFragment(); 38 } 39 40 private void setupTitleFragment() { 41 TitleView titleView = findViewById(R.id.title); 42 titleView.setTitle("RowsFragment"); 43 titleView.setOnSearchClickedListener(new View.OnClickListener() { 44 @Override 45 public void onClick(View view) { 46 Intent intent = new Intent(RowsActivity.this, SearchActivity.class); 47 startActivity(intent); 48 } 49 }); 50 51 BrowseFrameLayout frameLayout = findViewById(R.id.rows_frame); 52 TitleHelper titleHelper = new TitleHelper(frameLayout, titleView); 53 frameLayout.setOnFocusSearchListener(titleHelper.getOnFocusSearchListener()); 54 mRowsFragment.setTitleHelper(titleHelper); 55 } 56} 57