TabHost简单使用
来源:互联网 发布:手机上的数据处理软件 编辑:程序博客网 时间:2024/04/30 21:10
<TabHost xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > <LinearLayout android:id="@+id/linear1" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" > <TextView android:id="@+id/tab_text" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="hello" /> </LinearLayout> <LinearLayout android:id="@+id/linear2" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" > <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="world" /> </LinearLayout> <LinearLayout android:id="@+id/linear3" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" > </LinearLayout></TabHost>
代码 :
private TextView txt;private View view;private TabHost tabhost;@Overrideprotected void onCreate(Bundle savedInstanceState) {// TODO Auto-generated method stubsuper.onCreate(savedInstanceState);tabhost = getTabHost();// 设置使用TabHost布局view = LayoutInflater.from(this).inflate(R.layout.tableview,tabhost.getTabContentView(), true);// 添加标签页tabhost.addTab(tabhost.newTabSpec("tab1").setIndicator("hello").setContent(R.id.linear3));tabhost.addTab(tabhost.newTabSpec("tab2").setIndicator("world",getResources().getDrawable(R.drawable.ic_launcher)).setContent(R.id.linear2));// 当前选中,设置超出长度的默认为第一项tabhost.setCurrentTab(1);// 点击选项卡tabhost.setOnTabChangedListener(new OnTabChangeListener() {@Overridepublic void onTabChanged(String tabId) {tabhost.addTab(tabhost.newTabSpec("tab1").setIndicator("hello").setContent(R.id.linear1));// 清除tabhost.clearAllTabs();}});}
效果:
- TabHost简单使用
- Tabhost的简单使用
- tabHost的简单使用
- TabHost简单使用示例
- Tabhost的简单使用
- <TabHost> 简单使用
- tabhost简单使用及tabhost源码分析
- tabhost简单使用及tabhost源码分析
- Android---61---TabHost简单使用
- TabHost空间的简单使用
- tabHost选项卡的简单使用
- Tabhost使用
- TabHost使用
- TabHost使用
- Andriod TabHost的使用TabHost
- 简单的TabHost
- TabHost 简单使用方法
- Tabhost的简单运用
- hdu 3646 Fate Stay Night
- HDU1102Constructing Roads(MST)
- shell script: pattern match (模式识别)
- HDU1078(深搜+DP)
- 互联网的三大巨头 百度 阿里巴巴 腾讯(BAT)
- TabHost简单使用
- 通过eclipse查看Android源代码(Java)
- 生成20个1-100不重复的随机数
- sysu宿舍网络路由器分享——IPv6篇
- 链表翻转、左旋转字符串
- Fragment详解(一)--->核心基础以及Fragment与Activity传递数据完整示例
- HDU2532 && BNU6657:Engine(模拟)
- HD-1017 A Mathematical Curiosity 试题分析
- Spring使用配置文件读取jdbc.properties