Android的TabHost组件-android的学习之旅(四十)
TabHost简介
虽然,官方建议用Fagment取代TabHost,但是我们还是大概的介绍一下。TabHost是一种非常简单的组件,TabHost可以很方便的在窗口放置多个标签页,每一个标签页相当于获得了一个摆放位置。
注意
TabHost的内部需要两个组件一个是TabWidget和FrameLayout两个组件。
通话记录界面
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="@android:id/tabhost"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TabWidget
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@android:id/tabs"/>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@android:id/tabcontent">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:id="@+id/tab01">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="hello"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="hello"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:id="@+id/tab02">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="hello"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="hello"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:id="@+id/tab03">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="hello"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="hello"/>
</LinearLayout>
</FrameLayout>
</LinearLayout>
</TabHost>
package peng.liu.test;
import android.app.TabActivity;
import android.os.Bundle;
import android.widget.TabHost;
public class MainActivity extends TabActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TabHost tabHost = getTabHost();
TabHost.TabSpec tabSpec = tabHost.newTabSpec("tab01").setIndicator("已接电话").setContent(R.id.tab01);
tabHost.addTab(tabSpec);
TabHost.TabSpec tabSpec1 = tabHost.newTabSpec("tab02").setIndicator("呼叫电话").setContent(R.id.tab02);
TabHost.TabSpec tabSpec2 = tabHost.newTabSpec("tab03").setIndicator("未接电话").setContent(R.id.tab03);
tabHost.addTab(tabSpec1);
tabHost.addTab(tabSpec2);
}
}
效果图
Android的TabHost组件-android的学习之旅(四十)的更多相关文章
- 12.Android之Tabhost组件学习
TabHost是整个Tab的容器,TabHost的实现有两种方式: 第一种继承TabActivity,从TabActivity中用getTabHost()方法获取TabHost.各个Tab中的内容在布 ...
- Android四大组件之一Service介绍-android学习之旅(十二)
基本概念: service是android四大组件之一,运行在后台执行耗时操作,并不提供用户界面.其他组件如acticity可以通过startService启动该组件,也可以通过bindService ...
- Android学习笔记(四十):Preference的使用
Preference直译为偏好,博友建议翻译为首选项.一些配置数据,一些我们上次点击选择的内容,我们希望在下次应用调起的时候依旧有效,无须用户再一次进行配置或选择.Android提供preferenc ...
- Android学习笔记(四十):Preference使用
Preference从字面上看偏好,译为首选项. 一些配置数据,一些我们上次点击选择的内容.我们希望在下次应用调起的时候依旧有效,无须用户再一次进行配置或选择.Android提供preference这 ...
- android布局Relative和gridLayout-android学习之旅(十六)
Relative布局简介 相对布局的组件是由兄弟组件和父组价决定的,因此这种布局被称为相对布局. 属性设置介绍 RelativeLayout.Layoutparam中只能设置为true和false的属 ...
- android布局##TableLayout和FrameLayout-android学习之旅(十五)
TableLayout 表格布局 tablelayout简介 表格布局有TableLayout代表,但是它的本质定义仍然是线性管理器.表格布局采用行和列来管理UI,但是不需要明确的定义多少行,多少列, ...
- Android的ViewAnimator及其子类ViewSwitcher-android学习之旅(三十三)
ViewAnimator继承了FrameLayout,多个组件重合在一起,可以加入多个组件,然后切换的时候会有动画. ViewAnimator及其子类的继承关系 ViewAnimator常用属性 Vi ...
- 开发了5年android,我开始了go学习之旅
前言 做了近5年的android开发,最近项目也是不怎么忙,空闲的时候总会思考一些事情,不过作为移动开发,我个人觉得很有必要学习后台开发,由于公司是Go语言开发的,了解go语言一段时间后,我发现go语 ...
- android:id="@android:id/tabhost" 、android:id="@+id/llRoot" 、android:id="@id/llRoot" 之间的区别
由于快要放暑假了,所以最近这俩周把Android方面的知识复习一下,准备找个实习工作. 顺便把自己的总结更大家分享一下,共同进步,谢谢.... 一. android:id="@android ...
随机推荐
- javascript 手势(swipeLeft,swipeRight)滑动中使用css3动画卡顿,开启硬件加速
今天,在做一个移动端项目,遇到了css3动画卡顿的现象. 例图: 在手势滑动中(swipeLeft,swipeRight)遇到了动画卡顿的现象,最后使用了css3动画-webkit-transform ...
- mac电脑操作
1.在mac电脑上打开多个终端: command+n快捷键可以打开多个终端
- 腾讯云H5语音通信QoE优化
本文首发在云+社区,未经许可,不得转载. 云+导语:4月21日,腾讯云+社区在京举办"'音'你而来,'视'而可见--音视频技术开发实战沙龙",腾讯音视频实验室高级工程师张轲围绕网络 ...
- 【python进阶】Garbage collection垃圾回收2
前言 在上一篇文章[python进阶]Garbage collection垃圾回收1,我们讲述了Garbage collection(GC垃圾回收),画说Ruby与Python垃圾回收,Python中 ...
- tomcat连接池配置和使用
一种方法是在conf/context.xml文件中配置,配置oracle连接池的一个例子的context内容如下: <?xml version='1.0' encoding='utf-8'?&g ...
- ELK 6安装配置 nginx日志收集 kabana汉化
#ELK 6安装配置 nginx日志收集 kabana汉化 #环境 centos 7.4 ,ELK 6 ,单节点 #服务端 Logstash 收集,过滤 Elasticsearch 存储,索引日志 K ...
- 在Spring Boot中使用数据库事务
我们在前面已经分别介绍了如何在Spring Boot中使用JPA(初识在Spring Boot中使用JPA)以及如何在Spring Boot中输出REST资源(在Spring Boot中输出REST资 ...
- 复杂和遗留的数据库schema
本文作者:苏生米沿 本文地址:http://blog.csdn.net/sushengmiyan/article/details/50414652 In this chapter, we focus ...
- STATE(状态)模式
引子 场景 在我们软件开发的过程中,有许多对象是有状态的.而对象的行为会随着状态的改变而发生改变.例如开发一个电梯类,电梯有开门.关门.停止.运行等行为,同时电梯也会有开门状态.关门状态.停止状态.运 ...
- Linux基础指令
Linux基础指令 只写了最简单的一些文件操作,基本没有带参数 查看当前目录 pwd 跳转到某路径 cd 查看当前目录下的文件 ls ls -l // -l 查看详细信息 打开当前所在文件夹 open ...