计时器(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. Java 诞生的趣事

    ​ Java 命名的由来 Java是印度尼西亚爪哇岛的英文名称,因盛产咖啡而闻名.Java语言中的许多库类名称,多与咖啡有关:如JavaBeans(咖啡豆).NetBeans(网络豆)以及Object ...

  2. 在phpstorm中安装、配置和运行phpunit详细教程

    前提:安装了composer 一.安装phpunit组件 右键项目文件,composer---init composer,会生成一个composer.json文件 右键项目文件,composer--- ...

  3. web页面的时间传入servlet如何转换为可以存入MySQL的Date类型

    在web页面中当使用如下语句: <input type="date" name="startTime"/> 提交到servlet中 在servlet ...

  4. Netty源码分析--Channel注册(上)(五)

    其实在将这一节之前,我们来分析一个东西,方便下面的工作好开展. 打开启动类,最开始的时候创建了一个NioEventLoopGroup 事件循环组,我们来跟一下这个. 这里bossGroup, 我传入了 ...

  5. 解决wireshark打开错误

    错误提示如下: Lua: Error during loading: [string "/usr/share/wireshark/init.lua"]:44: dofile has ...

  6. 移动IM开发指南1:如何进行技术选型

    <移动IM开发指南>系列文章将会介绍一个IM APP的方方面面,包括技术选型.登陆优化等.此外,本文作者会结合他在网易云信多年iOS IM SDK开发的经验,深度分析实际开发中的各种常见问 ...

  7. 08、MySQL—字符串型

    字符串型 1.Char 定长字符:指定长度之后,系统一定会分配指定的空间用于存储数据 基本语法: char(L),L代表字符数(中文与英文字母一样),L长度为0到255 2.Varchar 变长字符: ...

  8. Redis 学习笔记(篇四):整数集合和压缩列表

    整数集合 Redis 中当一个集合(set)中只包含整数,并且元素不多时,底层使用整数集合实现,否则使用字典实现. 那么: 为什么会出现整数集合呢?都使用字典存储不行吗? 整数集合在 Redis 中的 ...

  9. 随时发布:REST API文档的代码仓库中的持续集成与协作

    本文主要内容:API文档提供了预测客户成功的关键路径:在代码附近的文档上进行协作可以更好地检查代码和文档文件,提高自动化效率,并专门针对文档进行质量测试:提供通用文档框架,标准,自动化和工具,以提高团 ...

  10. HBase Region重点剖析

    Region的概念 Region是HBase数据管理的基本单位.数据的move,数据的balance,数据的split,都是按照region来进行操作的. region中存储这用户的真实数据,而为了管 ...