计时器(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. spring cloud之eureka简介

    最近线上的接口出了一些问题,有一些可能不是代码的问题,但是由于是测试和其他方面的同事爆出来的,所以感觉对接口的监控应该提上日程. 经过搜索发现,spring cloud的eureka就是专门做这方面工 ...

  2. Nio编程模型总结

    终于,这两天的考试熬过去了, 兴致冲冲的来整理笔记来, 这篇博客是我近几天的NIO印象笔记汇总,记录了对Selector及Selector的重要参数的理解,对Channel的理解,常见的Channel ...

  3. 『 效率工具 』Spring Boot版的轻量级代码生成器,减少70%以上的开发任务

    一. 前言 之前很着迷于代码自动生成,减少写重复代码的工作量.网络上也搜索了很久,有基于插件的,有GUI的.但其配置和学习成本都比较高,都不是很如我意. 本想自己用SpringBoot写一个,在收集相 ...

  4. Unity Shader常用函数,标签,指令,宏总结(持续更新)

    极端常用: UnityObjectToClipPos(v.vertex); 最基本的顶点变换,模型空间 ==>裁剪空间 mul(unity_ObjectToWorld, v.vertex); 顶 ...

  5. 修改linux(kali)和windows双系统下默认启动系统和启动延时

    我的公众号,正在建设中,欢迎关注: windows和kali双系统安装完成后kali是默认的启动系统,现将windows设置为默认启动系统并更改选择系统等待时间 1.开机时当运行到系统选择菜单时记下w ...

  6. LR编写Socket脚本方法2(从文件读取报文)

      之前,给大家分享了LoadRunner编写socket协议脚本的基本方法与规则,今天给大家分享下,如何从本地文件,读取内容,并作为报文,发送到服务端:该方法也是在工作中遇到的一个难点,想通过这种方 ...

  7. 4.shell编程-文本处理三剑客之sed

    4.1.sed的选项 sed,流编辑器.对标准输出或文件进行逐行处理. 语法格式 第一种:stdout | sed [option] "pattern command" 第二种:s ...

  8. chromedriver配置

    需要先安装chrome浏览器,添加chrome源 sudo vim /etc/yum.repos.d/google-chrome.repo 添加以下内容 [google-chrome] name=go ...

  9. 【Spring源码解析】—— 策略模式在Spring中的应用

    一.         什么是策略模式 策略模式的定义/含义:策略本身就是为了实现某一个目标而采取的一种工作方式,因此只要能够达成目标,则采取哪一种策略都可以:因此多种实际的策略之间是相互平行的. 注意 ...

  10. 学习kafka自己发生的几个小错误记录

    一.  The method iterator() is ambiguous ConsumerIterator<byte[],byte[]> it =stream.iterator(); ...