计时器(Chronometer)、标签(TabHost)
计时器(Chronometer)
方法 |
描述 |
public Chronometer(Context context)【构造方法】 |
创建Chronometer对象 |
public long getBase() |
设置一个基准时间,可以通过完成 |
public void setFormat(String format) |
设置显示格式 |
public long getBase() |
返回设置的基准时间 |
public String getFormat() |
返回设置的显示格式 |
public void start() |
开始计时 |
public void stop() |
停止计时 |
public void setOnChronometerTickListener( Chronometer.OnChronometerTickListener listener) |
设置计时改变的监听事件 |

<Chronometer
android:id="@+id/chro"
android: layout_width="fill_parent"
android: layout_height="wrap_content"/>
<LinearLayout
android: layout_width="fill_parent"
android: layout_height="wrap_content">
<Button
android:id="@+id/CbtStart"
android: text="开始"
android: layout_width="wrap_content"
android: layout_height="wrap_content"
android:layout_weight="1"/>
<Button
android:id="@+id/CbtStop"
android: text="结束"
android: layout_width="wrap_content"
android: layout_height="wrap_content"
android:layout_weight="1"/>
</LinearLayout>

标签(TabHost)
方式一:直接继承TabActivity类
tab.xml

1 public class Tabhost extends TabActivity {
2 protected void onCreate(Bundle savedInstanceState) {
3 super.onCreate(savedInstanceState);
4 TabHost tab=getTabHost(); //取得TabHost类的对象
5 LayoutInflater . from (this).
6 inflate(R.layout.tab, //定义转换的布局管理器
7 tab.getTabContentView(), //指定标签增加的容器
8 true); //实例化布局管理器中的组件
9 //选项
10 TabSpec sp1=tab.newTabSpec ("tab1");
11 //设置标签的标题,设置标签的显示内容
12 sp1.setIndicator("选项1").setContent (R.id.Ttv01);
13 tab.addTab(sp1); //设置标签的tab
14
15 TabSpec sp2=tab.newTabSpec ("tab2");
16 sp2.setIndicator("选项2").setContent (R.id.Ttv02);
17 tab.addTab (sp2);
18
19 TabSpec sp3=tab.newTabSpec ("tab3");
20 sp3.setIndicator("选项3").setContent (R.id.Ttv03);
21 tab.addTab (sp3);
22 }
23 }

TabHost.TabSpec
TabHost类增加每一个选项需要增加多个TabHost.TabSpec的对象,
此类事TabHost定义的内部类
方式二:在布局文件中定义组件
使用<TabHost>标签做根标签

<TabHost
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/Tll01"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:src="@drawable/a"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:text="哈哈哈"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:id="@+id/Tll02"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:src="@drawable/b"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:text="哈哈哈"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
</TabHost>


1 protected void onCreate(Bundle savedInstanceState) {
2 super.onCreate(savedInstanceState);
3 TabHost tab=getTabHost();
4 LayoutInflater.from(this).
5 inflate(R.layout.tab0, //定义转换的布局管理器
6 tab.getTabContentView(), //指定标签增加的容器
7 true); //实例化布局管理器中的组件
8 //选项
9 TabSpec sp1=tab.newTabSpec("tab1");
10 //设置标签的标题,设置标签的显示内容
11 sp1.setIndicator("选项1").setContent(R.id.Tll01);
12 tab.addTab(sp1); //设置标签的tab
13
14 TabSpec sp2=tab.newTabSpec("tab2");
15 sp2.setIndicator("选项2").setContent(R.id.Tll02);
16 tab.addTab(sp2);
17 }

计时器(Chronometer)、标签(TabHost)的更多相关文章
- 计时器Chronometer和时钟(AnalogClock和DigitalClock)
计时器Chronometer和时钟(AnalogClock和DigitalClock) (1)Android提供了两个时钟组件:AnalogClock和DigitalClock,DigitalCloc ...
- Android学习笔记(20):时钟(AnalogClock和TextClock)和计时器(Chronometer)
时钟文本TextClock继承自TextView.是用于显示当前时间的文本框. TextClock支持的XML属性和相关方法 XML属性 相关方法 说明 android:format12Hour se ...
- 计时器chronometer补充
项目中要实现关于安卓控件chronometer这部分的功能需求: 1.计时器的功能对用户答题时间进行时间统计,用户答完该题,进入下一题,计时器接续上一题的结束时间继续计时: 2.用户可以跳出答题界面, ...
- UI组件之TextView及其子类(五)计时器Chronometer
Chronometer直接继承了TextView组件,它会显示一段文本,显示从某个事实上时间開始.一共过了多长时间.我们看Chronometer的源代码: watermark/2/text/aHR0c ...
- 计时器Chronometer
布局文件很简单 <Chronometer android:id="@+id/test" android:layout_width="wrap_content&quo ...
- Android中Chronometer计时器的简单使用
场景 实现效果如下 注: 博客: https://blog.csdn.net/badao_liumang_qizhi 关注公众号 霸道的程序猿 获取编程相关电子书.教程推送与免费下载. 实现 将布局改 ...
- Android零基础入门第63节:过时但仍值得学习的选项卡TabHost
原文:Android零基础入门第63节:过时但仍值得学习的选项卡TabHost 由于前几天参加一个学习培训活动,几乎每天都要从早晨7点到晚上一两点,没有什么时间来分享,实在抱歉中间断更了几天.从今天开 ...
- Android:TabHost实现Tab切换
TabHost是整个Tab的容器,包含TabWidget和FrameLayout两个部分,TabWidget是每个Tab的表情,FrameLayout是Tab内容. 实现方式有两种: 1.继承TabA ...
- android使用tabhost实现导航
参考 http://blog.csdn.net/xixinyan/article/details/6771341 http://blog.sina.com.cn/s/blog_6b04c8eb0101 ...
随机推荐
- 解决vuejs 创建数据后设置对象的属性实现不了双向绑定问题
抛出踩坑:vue创建后的数据,自定义设置对象的属性,实现不了双向绑定 当业务场景,需要在请求接口数据新增自定义的属性 let foodList = [ {title: '回锅肉', price: 99 ...
- vue复选框获取值的补充
要通过vue的v-model获取选中复选框的值,可以用遍历对象的方式获取,代码如下: <!DOCTYPE html> <html xmlns="http://www.w3. ...
- vsphere网络
物理网络 物理机间建立的网络,VMware ESXi运行于物理机之上 虚拟网络 单台物理机上运行的虚拟机之间通信形成的逻辑网络. 一.网络概述 1. 物理以太网交换机 2.vSphere标准交换机 虚 ...
- Junit4使用详解二:Junit4运行流程
1.新建一个测试用例,把下面的四个方法勾选以便查看效果 2.我们在各个方法里面写上输出语句 3.运行之后我们可以发现,它的执行顺序是这样的 注:junit4中的运行流程 1.@BeforeClass修 ...
- Ceph原理动画演示
动图生动刻画Ceph的基本原理之集群搭建及数据写入流程:)
- 渗透测试工具SQLmap
一.简介 SQLmap 是一款用 Python 编写的开源渗透测试工具,用来自动检测和利用 SQL 注入漏洞. 二.Windows 下安装 2.1 安装 Python 环境 注:Python 3.0会 ...
- Wannafly挑战赛1:Treepath(DFS统计)
题目链接 题意 给出一棵树,问长度为偶数的路径数有多少. 思路 记录路径长度为奇数的数目和为偶数的数目,然后 n * (n-1) / 2 求和即可. #include <bits/stdc++. ...
- Hyperledger Fabric 命令整理
Peer节点命令 Peer node start 启动一个Peer节点: peer node start status 获取当前节点的状态信息 peer node status reset 重置当前节 ...
- kuangbin专题 专题一 简单搜索 Prime Path POJ - 3126
题目链接:https://vjudge.net/problem/POJ-3126 题意:给你两个四位的素数N,M,每次改变N四位数中的其中一位,如果能经过有限次数的替换变成四位数M,那么求出最少替换次 ...
- 自我救赎 → 利用 IDEA 和 Spring Boot 搭建 SSM
前言 开心一刻 儿子读高中放学回来了,一向不管他学习的我突然来了兴趣,想看看他的学习他的状况,抄起他的数学习题看了起来,当看到 1 x 2 x 3 x 4 x 5 x 6 x 7 x 8 x 9 x ...