private int hourOfDay, minute;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button = (Button) findViewById(R.id.button);
Calendar calendar = Calendar.getInstance();
hourOfDay = calendar.get(Calendar.HOUR);
minute = calendar.get(Calendar.MINUTE);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
TimePickerDialog pickerDialog = new TimePickerDialog(MainActivity.this, new OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
// TODO Auto-generated method stub
Toast.makeText(MainActivity.this, hourOfDay + "时" + minute + "分", 1).show();
;
}
}, hourOfDay, minute, true);
pickerDialog.show();
}
});
}