android中關於時間的控件


1.日期選擇器

<DatePicker
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"></DatePicker>

 

 

2.時間選擇器

<TimePicker
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"></TimePicker>

 

 

3.計時器

其中常用的五種方法

(1)setBase()  設置計時器的起始時間

(2)setForma()  設置計時器的顯示時間格式

(3)start()  指定開始計時

(4)stop() 指定停止計時

(5)setOnChronometerTickListene()   為計時器綁定事件監聽器,當計時器改變時觸發該監聽器

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <Chronometer
        android:id="@+id/jishi"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:format="以用時間%s"
        />

</android.support.constraint.ConstraintLayout>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM