Android左右切换的标签
2016-06-29 10:42
573 查看
/**
* 创建框架,2个标签
* 1.网络音频
* 2.本地下载
* **/
private void createFrame()
{
TabHost tabHost = this.getTabHost();
//start:这里创建一个网络音频的标签
//创建一个intent,用于跳转到标签对应的activity
Intent networkIntent = new Intent();
networkIntent.setClass(MainActivity.this, NetworkActivity.class);
TabHost.TabSpec networkSpec= tabHost.newTabSpec("network");//创建标签页
networkSpec.setIndicator(AppConstant.MainConstant.netTabName);//设置信息显示板,也就是标签的名称
networkSpec.setContent(networkIntent);//设置标签对应的内容
tabHost.addTab(networkSpec);//添加标签
//end
//start:这里创建一个本地下载的标签
Intent localIntent = new Intent();
localIntent.setClass(MainActivity.this, LocalDownActivity.class);
TabHost.TabSpec localSpec=tabHost.newTabSpec("local");
localSpec.setIndicator(AppConstant.MainConstant.localTabName);
localSpec.setContent(localIntent);
tabHost.addTab(localSpec);
//end
////设置当前显示哪个标签
tabHost.setCurrentTab(0);
}
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<!--用于展示每个标签对应的内容布局,放在前面就是让标签在下方。-->
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
/>
<!--用于展示标签-->
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
/>
</LinearLayout>
</TabHost>
* 创建框架,2个标签
* 1.网络音频
* 2.本地下载
* **/
private void createFrame()
{
TabHost tabHost = this.getTabHost();
//start:这里创建一个网络音频的标签
//创建一个intent,用于跳转到标签对应的activity
Intent networkIntent = new Intent();
networkIntent.setClass(MainActivity.this, NetworkActivity.class);
TabHost.TabSpec networkSpec= tabHost.newTabSpec("network");//创建标签页
networkSpec.setIndicator(AppConstant.MainConstant.netTabName);//设置信息显示板,也就是标签的名称
networkSpec.setContent(networkIntent);//设置标签对应的内容
tabHost.addTab(networkSpec);//添加标签
//end
//start:这里创建一个本地下载的标签
Intent localIntent = new Intent();
localIntent.setClass(MainActivity.this, LocalDownActivity.class);
TabHost.TabSpec localSpec=tabHost.newTabSpec("local");
localSpec.setIndicator(AppConstant.MainConstant.localTabName);
localSpec.setContent(localIntent);
tabHost.addTab(localSpec);
//end
////设置当前显示哪个标签
tabHost.setCurrentTab(0);
}
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<!--用于展示每个标签对应的内容布局,放在前面就是让标签在下方。-->
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
/>
<!--用于展示标签-->
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
/>
</LinearLayout>
</TabHost>
相关文章推荐
- 表格标签table深入了解
- WEB标准网页布局中尽量不要使用的HTML标签
- 如何使用jquery easyui创建标签组件
- web标准知识――用途相似的标签
- 详解Android TabHost的多种实现方法 附源码下载
- h1标签的使用技巧
- 探讨JavaScript标签位置的存放与功能有无关系
- HTML代码中标签的全部属性 中文注释说明
- 第九章之路径分页标签与徽章组件
- javascript实现label标签跳出循环操作
- Bootstrap每天必学之标签与徽章
- jQuery EasyUI 布局之动态添加tabs标签页
- jQuery+CSS实现滑动的标签分栏切换效果
- jquery 实现两Select 标签项互调示例代码
- 详解jQuery Mobile自定义标签
- jQuery获取标签文本内容和html内容的方法
- JavaScript获取并更改input标签name属性的方法
- css样式标签和js语法属性区别
- JSP自定义标签入门学习
- JSP中param标签用法实例分析