TimePickerDialog

叶健柏
2023-12-01
package com.pingyijinren.helloworld.activity;

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


import com.pingyijinren.helloworld.R;
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
    private Button button;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        button=(Button)findViewById(R.id.button);
        button.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        TimePickerDialog timePickerDialog=new TimePickerDialog(this, new TimePickerDialog.OnTimeSetListener() {
            @Override
            public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
                Toast.makeText(MainActivity.this,hourOfDay+"/"+minute,Toast.LENGTH_SHORT).show();
            }
        },15,58,true);
        timePickerDialog.show();
    }
}

 

转载于:https://www.cnblogs.com/zqxLonely/p/5553388.html

 类似资料:

相关阅读

相关文章

相关问答