计时器(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. Servlet 3.0异步特性初探

    Servlet 是 Java 为了编写服务端程序而定义的一个接口规范,在 Servlet 3.0 以后支持了异步的操作. 最近项目添加了一个代码热部署的功能,在客户端输入信号,信号到达 Web 服务器 ...

  2. 高并发 Nginx+Lua OpenResty系列(8)——Lua模版渲染

    模版渲染 动态web网页开发是Web开发中一个常见的场景,比如像京东商品详情页,其页面逻辑是非常复杂的,需要使用模板技术来实现.而Lua中也有许多模板引擎,如目前京东在使用的lua-resty-tem ...

  3. 最全java多线程总结2--如何进行线程同步

      上篇对线程的一些基础知识做了总结,本篇来对多线程编程中最重要,也是最麻烦的一个部分--同步,来做个总结.   创建线程并不难,难的是如何让多个线程能够良好的协作运行,大部分需要多线程处理的事情都不 ...

  4. SkyWorking基础:6.2版本安装部署

    就在今天,SkyWorking发布了6.2版本. 概述 什么是SkyWorking SkyWalking是观察性分析平台和应用性能管理系统. 提供分布式追踪.服务网格遥测分析.度量聚合和可视化一体化解 ...

  5. yii后台模板标签

    yii模板中的label标签 <?php echo $form->labelEx($model,'name'); ?> 编译后: <label for="Projec ...

  6. idea 创建maven项目(一)

    1.新建 Project 2.点击Next 3.填写组织名称和项目名称,点击next 4.在你的本地仓库目录下创建settings.xml文件,把mirror的url改成阿里云的 <?xml v ...

  7. Akka-CQRS(14)- Http标准安全解决方案:OAuth2-资源使用授权

    上一篇讨论了SSL/TLS安全连接,主要是一套在通信层面的数据加密解决方案.但我们更需要一套方案来验证客户端.要把不能通过验证的网络请求过滤掉. OAuth2是一套行业标准的网络资源使用授权协议,也就 ...

  8. Programming In Lua 第九章

    1, 2, 3, 4, 5, 6, 第6点很关键:先是调用消费者,来唤醒一个协同例程producer,协同例程producer读取一个数据x后调用send.send函数中调用yield(x),该函数将 ...

  9. asp.net core 系列之Dependency injection(依赖注入)

    这篇文章主要讲解asp.net core 依赖注入的一些内容. ASP.NET Core支持依赖注入.这是一种在类和其依赖之间实现控制反转的一种技术(IOC). 一.依赖注入概述 1.原始的代码 依赖 ...

  10. JavaScript原型和原型链( prototype 与 __proto__ )

    一.函数对象 所有引用类型(函数.数组.对象)都拥有__proto__属性(隐式原型) 所有函数拥有 prototype 属性(显式原型)(仅限函数) 原型对象:拥有 prototype 属性的对象, ...