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

Android時間選擇器示例含代碼

Android時間選擇器示例

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

android.widget.TimePicker是FrameLayout類的子類。愛掏網 - it200.com

Android時間選擇器示例

讓我們看一個簡單的Android時間選擇器示例。愛掏網 - 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;
    }

}

輸出:

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

返回頂部

主站蜘蛛池模板: 久久久久亚洲国产| 成人在线中文字幕 | 久久久久久久久久久久一区二区 | av超碰 | 一级高清视频 | 午夜精品久久久久久久久久久久 | 日韩毛片免费看 | 欧美国产精品一区二区三区 | 一区二区亚洲 | 久久久这里只有17精品 | 久久精品无码一区二区三区 | 91精品久久久 | 久久久久黄 | 91精品国产99久久 | 亚洲综合二区 | 精品国产乱码久久久久久a丨 | 欧美日韩国产一区二区三区 | 国产日韩欧美精品一区二区 | 99资源站 | 天天操综合网 | 99爱视频 | 亚洲 欧美 日韩在线 | 亚洲精品视频在线观看视频 | 香蕉视频91| 日韩欧美网| 91精品国产91久久综合桃花 | 99久久精品免费看国产高清 | 久久综合九九 | 一区二区播放 | 日本久草 | 日韩视频在线免费观看 | 亚洲日韩中文字幕一区 | 黄色一级电影免费观看 | 国产精品国产三级国产aⅴ无密码 | 99热欧美 | 国产免费一区二区三区免费视频 | 99精品国产一区二区三区 | 一区视频在线 | 91精品国产91久久久久久 | 久久国产成人 | 久久久爽爽爽美女图片 |