一区二区日本_久久久久久久国产精品_无码国模国产在线观看_久久99深爱久久99精品_亚洲一区二区三区四区五区午夜_日本在线观看一区二区

Android時間選擇器示例含代碼

Android時間選擇器示例

Android時間選擇器 小部件用于選擇日期。愛掏網(wǎng) - it200.com它允許你按小時和分鐘選擇時間。愛掏網(wǎng) - it200.com你不能按秒選擇時間。愛掏網(wǎng) - it200.com

android.widget.TimePicker是FrameLayout類的子類。愛掏網(wǎng) - it200.com

Android時間選擇器示例

讓我們看一個簡單的Android時間選擇器示例。愛掏網(wǎng) - it200.com

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>  
<RelativeLayout 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="example.javatpoint.com.timepicker.MainActivity">  

    <TextView  
        android:id="@+id/textView1"  
        android:layout_width="wrap_content"  
        android:layout_height="wrap_content"  
        android:layout_above="@+id/button1"  
        android:layout_alignParentLeft="true"  
        android:layout_alignParentStart="true"  
        android:layout_marginBottom="102dp"  
        android:layout_marginLeft="30dp"  
        android:layout_marginStart="30dp"  
        android:text="" />  

    <Button  
        android:id="@+id/button1"  
        android:layout_width="wrap_content"  
        android:layout_height="wrap_content"  
        android:layout_alignParentBottom="true"  
        android:layout_centerHorizontal="true"  
        android:layout_marginBottom="20dp"  
        android:text="Change Time" />  

    <TimePicker  
        android:id="@+id/timePicker"  
        android:layout_width="wrap_content"  
        android:layout_height="wrap_content"  
        android:layout_above="@+id/textView1"  
        android:layout_centerHorizontal="true"  
        android:layout_marginBottom="36dp" />  
</RelativeLayout>  

Activity類

package example.javatpoint.com.timepicker;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.TimePicker;

public class MainActivity extends AppCompatActivity {
    TextView textview1;
    TimePicker timepicker;
    Button changetime;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        textview1=(TextView)findViewById(R.id.textView1);
        timepicker=(TimePicker)findViewById(R.id.timePicker);
        //Uncomment the below line of code for 24 hour view
        timepicker.setIs24HourView(true);
        changetime=(Button)findViewById(R.id.button1);

        textview1.setText(getCurrentTime());

        changetime.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View view) {
                textview1.setText(getCurrentTime());
            }
        });

    }

    public String getCurrentTime(){
        String currentTime="Current Time: "+timepicker.getCurrentHour()+":"+timepicker.getCurrentMinute();
        return currentTime;
    }

}

輸出:

聲明:所有內(nèi)容來自互聯(lián)網(wǎng)搜索結果,不保證100%準確性,僅供參考。如若本站內(nèi)容侵犯了原著者的合法權益,可聯(lián)系我們進行處理。
發(fā)表評論
更多 網(wǎng)友評論0 條評論)
暫無評論

返回頂部

主站蜘蛛池模板: 久久久久国产一级毛片 | 人人看人人草 | 日本一区二区三区在线观看 | 伊人免费网 | 国产小视频在线 | 久久久久成人精品免费播放动漫 | 亚洲成人免费 | 中文字幕成人av | av黄色免费在线观看 | 欧美一区2区三区3区公司 | 日韩免费三级 | 欧产日产国产精品视频 | 超碰成人免费观看 | 成人免费网站www网站高清 | 一区二区三区亚洲 | 亚洲欧美视频在线观看 | 国产精品二区三区 | 亚洲日日夜夜 | 国产精品69毛片高清亚洲 | 毛片黄片| 中文一区 | 亚洲国产精品人人爽夜夜爽 | 久久亚洲一区二区三区四区 | 日韩欧美国产精品一区二区 | 欧美二区在线 | 成人一区二区三区在线观看 | 91免费观看视频 | 亚洲免费精品一区 | 欧美人成在线视频 | 综合网中文字幕 | 亚洲精品美女视频 | 久久欧美高清二区三区 | 亚州一区二区三区 | 国产精品国产a级 | 国产欧美一区二区三区久久 | 日韩一二三区视频 | 天天综合91| 91精品国产91久久久久久吃药 | 91亚洲精品在线观看 | 亚洲免费人成在线视频观看 | 国产成人小视频 |