TabHost使用(三)
来源:互联网 发布:淘宝怎么定做地毯 编辑:程序博客网 时间:2024/06/06 09:03
第一步:创建布局文件
<?xml version="1.0" encoding="utf-8"?><!-- 这里是根节点布局 --><FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent" android:layout_height="fill_parent"><!-- 第一个Tab 对应的布局 --><LinearLayout android:id="@+id/widget_layout_Blue"android:layout_width="fill_parent" android:layout_height="fill_parent"androidrientation="vertical"><EditText android:id="@+id/widget34" android:layout_width="fill_parent"android:layout_height="wrap_content" android:text="EditText"android:textSize="18sp"></EditText><Button android:id="@+id/widget30" android:layout_width="wrap_content"android:layout_height="wrap_content" android:text="Button"></Button></LinearLayout><!-- 第二个Tab 对应的布局 --><LinearLayout android:id="@+id/widget_layout_red"android:layout_width="fill_parent" android:layout_height="fill_parent"androidrientation="vertical"><AnalogClock android:id="@+id/widget36"android:layout_width="wrap_content" android:layout_height="wrap_content"></AnalogClock></LinearLayout><!-- 第三个Tab 对应的布局 --><LinearLayout android:id="@+id/widget_layout_green"android:layout_width="fill_parent" android:layout_height="fill_parent"androidrientation="vertical"><RadioGroup android:id="@+id/widget43"android:layout_width="166px" android:layout_height="98px"androidrientation="vertical"><RadioButton android:id="@+id/widget44"android:layout_width="wrap_content" android:layout_height="wrap_content"android:text="RadioButton"></RadioButton><RadioButton android:id="@+id/widget45"android:layout_width="wrap_content" android:layout_height="wrap_content"android:text="RadioButton"></RadioButton></RadioGroup></LinearLayout></FrameLayout>
第二步:测试类
public class TabHostTestActivity extends TabActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TabHost tabHost=getTabHost();
//解析布局文件
LayoutInflater.from(this).inflate(R.layout.main, tabHost.getTabContentView(), true);
tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("tab1").setContent(R.id.widget_layout_Blue));
tabHost.addTab(tabHost.newTabSpec("tab2").setIndicator("tab2").setContent(R.id.widget_layout_green));
tabHost.addTab(tabHost.newTabSpec("tab3").setIndicator("tab3").setContent(R.id.widget_layout_red));
tabHost.setCurrentTab(1);
}
}
第三步:演示效果
- TabHost使用(三)
- TabHost基本实现(三)
- tabhost基本用法(三)
- TabHost使用(一)
- TabHost使用(二)
- TabHost的使用(三):动态添加Tab
- Fragment使用(三):fragment+viewPageIndicator的组合使用,类似Tabhost
- tabhost的使用(1)
- android 音乐播放器制作 之Tabhost 简单使用(三)(1)
- android studio tabhost基础 多功能时钟app 使用sharedpreference存储闹钟数据(三)
- Tabhost使用
- TabHost使用
- TabHost使用
- android Tabhost部件(三)--使用自定义view和fragement实现类似TabHost样式
- Andriod TabHost的使用TabHost
- TabHost三种方法
- tabhost 得使用和学习(2)
- Android入门之TabHost三(不用xml,纯java)
- 任务切换过程。
- DrawText换行显示的方法
- Linux下USB鼠标驱动完全注释
- lucene笔记
- 在Qt中设置休眠
- TabHost使用(三)
- net Winform socket 套接字聊天室客户端和服务端 源码
- MFC 中的多线程(Work线程)
- Viddy排名App Store免费应用第二,力压Instagram&Draw Sth
- oracle存储过程
- ADB工具调试
- 如何编写Linux 下的 USB 键盘驱动
- Repeater嵌套
- 不扶才是最好的搀扶