Skip to content

Instantly share code, notes, and snippets.

@sakurabird
Created October 10, 2013 19:02
Show Gist options
  • Save sakurabird/6923659 to your computer and use it in GitHub Desktop.
Save sakurabird/6923659 to your computer and use it in GitHub Desktop.
android 時刻ダイアログ
protected void showTimeDialog() {
final Calendar calendar = Calendar.getInstance();
final int hour = calendar.get(Calendar.HOUR_OF_DAY);
final int minute = calendar.get(Calendar.MINUTE);
final TimePickerDialog timePickerDialog = new TimePickerDialog(this,
new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
Toast.makeText(MainActivity.this,
String.valueOf(hourOfDay) + ":" + String.valueOf(minute),
Toast.LENGTH_SHORT).show();
}
}, hour, minute, true);
timePickerDialog.show();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment