• Android 通过findViewById方式创建TabHost


     1     package org.shuxiang.tabhostsample;  
     2       
     3     import android.os.Bundle;  
     4     import android.app.ActivityGroup;  
     5     import android.content.Intent;  
     6     import android.widget.TabHost;  
     7       
     8     public class MainActivity extends ActivityGroup  
     9     {  
    10         private String tabHost1 = "A";  
    11         private String tabHost2 = "B";  
    12         private String tabHost3 = "C";  
    13         private TabHost tabHost;  
    14       
    15         @Override  
    16         public void onCreate(Bundle savedInstanceState) {  
    17             super.onCreate(savedInstanceState);  
    18             setContentView(R.layout.tabhost);  
    19               
    20             tabHost = (TabHost) findViewById(android.R.id.tabhost);  
    21       
    22             tabHost.setup(getLocalActivityManager());  
    23               
    24             tabHost.setCurrentTab(0);  
    25             tabHost.addTab(tabHost.newTabSpec(tabHost1)  
    26             .setIndicator(tabHost1).  
    27             setContent(new Intent(MainActivity.this, Tab1.class)));  
    28             tabHost.addTab(tabHost.newTabSpec(tabHost2)  
    29             .setIndicator(tabHost2)  
    30             .setContent(new Intent(MainActivity.this, Tab2.class)));  
    31             tabHost.addTab(tabHost.newTabSpec(tabHost3)  
    32             .setIndicator(tabHost3)  
    33             .setContent(new Intent(MainActivity.this, Tab3.class)));  
    34       
    35         }  
    36       
    37       
    38     }  
  • 相关阅读:
    SPOJ 149 FSHEEP Fencing in the Sheep ( 计算几何 + 二分 )
    UVa 11806
    UVa 1445
    HDU 4725 The Shortest Path in Nya Graph( 建图 + 最短路 )
    HDU 4661 Message Passing ( 树DP + 推公式 )
    从远程库克隆库
    添加远程库
    远程仓库
    删除文件
    撤销修改
  • 原文地址:https://www.cnblogs.com/lihaibo-Leao/p/3533193.html
Copyright © 2020-2023  润新知