• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2008 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 com.example.android.apis.view;
18 
19 import com.example.android.apis.R;
20 
21 import android.app.TabActivity;
22 import android.os.Bundle;
23 import android.view.View;
24 import android.widget.TabHost;
25 import android.widget.TextView;
26 
27 /**
28  * Uses a right gravity for the TabWidget.
29  */
30 public class Tabs6 extends TabActivity implements TabHost.TabContentFactory {
31 
32     @Override
onCreate(Bundle savedInstanceState)33     protected void onCreate(Bundle savedInstanceState) {
34         super.onCreate(savedInstanceState);
35 
36         setContentView(R.layout.tabs_right_gravity);
37 
38         final TabHost tabHost = getTabHost();
39         tabHost.addTab(tabHost.newTabSpec("tab1")
40                 .setIndicator("tab1", getResources().getDrawable(R.drawable.star_big_on))
41                 .setContent(this));
42         tabHost.addTab(tabHost.newTabSpec("tab2")
43                 .setIndicator("tab2")
44                 .setContent(this));
45         tabHost.addTab(tabHost.newTabSpec("tab3")
46                 .setIndicator("tab3")
47                 .setContent(this));
48     }
49 
createTabContent(String tag)50     public View createTabContent(String tag) {
51         final TextView tv = new TextView(this);
52         tv.setText("Content for tab with tag " + tag);
53         return tv;
54     }
55 }
56