1 /* 2 * Copyright (C) 2009 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.widget.cts; 18 19 import android.app.TabActivity; 20 import android.os.Bundle; 21 import android.view.View; 22 import android.widget.TabHost; 23 import android.widget.TextView; 24 25 import com.android.cts.stub.R; 26 27 /** 28 * A minimal application for TabHost test. 29 * It contains an initial tab whose tag is INITIAL_TAB_TAG and label is INITIAL_TAB_LABEL. 30 */ 31 public class TabHostStubActivity extends TabActivity { 32 public static final String INITIAL_TAB_TAG = "initial tag"; 33 public static final String INITIAL_TAB_LABEL = "initial label"; 34 public static final String INITIAL_VIEW_TEXT = "initial view text"; 35 36 @Override 37 public void onCreate(Bundle savedInstanceState) { 38 super.onCreate(savedInstanceState); 39 setContentView(R.layout.tabhost_layout); 40 41 TabHost tabHost = getTabHost(); 42 43 // at least one tab 44 tabHost.addTab(tabHost.newTabSpec(INITIAL_TAB_TAG) 45 .setIndicator(INITIAL_TAB_LABEL) 46 .setContent(new MyTabContentFactory())); 47 } 48 49 private class MyTabContentFactory implements TabHost.TabContentFactory { 50 public View createTabContent(String tag) { 51 final TextView tv = new TextView(getApplicationContext()); 52 tv.setText(INITIAL_VIEW_TEXT); 53 return tv; 54 } 55 } 56 } 57