计时器(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)的更多相关文章

  1. 计时器Chronometer和时钟(AnalogClock和DigitalClock)

    计时器Chronometer和时钟(AnalogClock和DigitalClock) (1)Android提供了两个时钟组件:AnalogClock和DigitalClock,DigitalCloc ...

  2. Android学习笔记(20):时钟(AnalogClock和TextClock)和计时器(Chronometer)

    时钟文本TextClock继承自TextView.是用于显示当前时间的文本框. TextClock支持的XML属性和相关方法 XML属性 相关方法 说明 android:format12Hour se ...

  3. 计时器chronometer补充

    项目中要实现关于安卓控件chronometer这部分的功能需求: 1.计时器的功能对用户答题时间进行时间统计,用户答完该题,进入下一题,计时器接续上一题的结束时间继续计时: 2.用户可以跳出答题界面, ...

  4. UI组件之TextView及其子类(五)计时器Chronometer

    Chronometer直接继承了TextView组件,它会显示一段文本,显示从某个事实上时间開始.一共过了多长时间.我们看Chronometer的源代码: watermark/2/text/aHR0c ...

  5. 计时器Chronometer

    布局文件很简单 <Chronometer android:id="@+id/test" android:layout_width="wrap_content&quo ...

  6. Android中Chronometer计时器的简单使用

    场景 实现效果如下 注: 博客: https://blog.csdn.net/badao_liumang_qizhi 关注公众号 霸道的程序猿 获取编程相关电子书.教程推送与免费下载. 实现 将布局改 ...

  7. Android零基础入门第63节:过时但仍值得学习的选项卡TabHost

    原文:Android零基础入门第63节:过时但仍值得学习的选项卡TabHost 由于前几天参加一个学习培训活动,几乎每天都要从早晨7点到晚上一两点,没有什么时间来分享,实在抱歉中间断更了几天.从今天开 ...

  8. Android:TabHost实现Tab切换

    TabHost是整个Tab的容器,包含TabWidget和FrameLayout两个部分,TabWidget是每个Tab的表情,FrameLayout是Tab内容. 实现方式有两种: 1.继承TabA ...

  9. android使用tabhost实现导航

    参考 http://blog.csdn.net/xixinyan/article/details/6771341 http://blog.sina.com.cn/s/blog_6b04c8eb0101 ...

随机推荐

  1. 30211Java_类

    类 类:我们叫做class. 对象:叫做Object,instance(实例).某个类的对象,某个类的实例.是一样的意思.1.对象是具体的事物;类是对对象的抽象;2.类可以看成一类对象的模板,对象可以 ...

  2. 《JavaScript 高级程序设计》读书笔记

    文章目录 第三章 基本语法 第四章 变量.作用域和内存问题 第五章 应用类型 1. Array 类型 2. RegExp 类型 3. Function 类型 4. String 类型 第六章 面向对象 ...

  3. Centos7安装Typecho详细教程

    Centos7安装Typecho详细教程   首先搭建LAMPH环境 L linux 服务器(centos或者ubunt) .A Apache .M mysql .P PHP 安装Apache.PHP ...

  4. 【Mysql】重启: mysql.service: Service hold-off time over, scheduling restart.

    参考链接:http://sharong.iteye.com/blog/2262760 重启mysql服务器 (/etc/init.d/mysql stop  /etc/init.d/mysql sta ...

  5. 长春理工大学第十四届程序设计竞赛(重现赛)H

    H .Arithmetic Sequence 题目链接:https://ac.nowcoder.com/acm/contest/912/H 题目 数竞选手小r最喜欢做的题型是数列大题,并且每一道都能得 ...

  6. Analysis of requirement specification of parking management system

    Analysis of requirement specification of parking management system PURPOSE OF THE SYSTEM The parking ...

  7. WIFI密码破解全攻略

    开篇介绍 目前无线网络加密技术日益成熟.以前的wep加密方式日渐淘汰,因为这种加密方式非常容易破解,当然现在还是有不少使用这种加密方式无线网络.现在大部分的无线网络都是使用wpa/wpa2方式来加密的 ...

  8. UVa 1440:Inspection(带下界的最小流)***

    https://vjudge.net/problem/UVA-1440 题意:给出一个图,要求每条边都必须至少走一次,问最少需要一笔画多少次. 思路:看了好久才勉强看懂模板.良心推荐:学习地址. 看完 ...

  9. Codeforces Gym100623J:Just Too Lucky(数位DP)

    http://codeforces.com/gym/100623/attachments 题意:问1到n里面有多少个数满足:本身被其各个数位加起来的和整除.例如120 % 3 == 0,111 % 3 ...

  10. C++20 的 Modules

    最近看了两篇关于 C++ 20 Modules 很有意思的文章,戳: <Understanding C++ Modules: Part 1: Hello Modules, and Module ...