Last active
December 25, 2015 05:19
-
-
Save sakurabird/6923647 to your computer and use it in GitHub Desktop.
android 日付ダイアログ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void showDateDialog() { | |
final Calendar calendar = Calendar.getInstance(); | |
final int year = calendar.get(Calendar.YEAR); | |
final int month = calendar.get(Calendar.MONTH); | |
final int day = calendar.get(Calendar.DAY_OF_MONTH); | |
final DatePickerDialog datePickerDialog = new DatePickerDialog( | |
this, | |
new DatePickerDialog.OnDateSetListener() { | |
@Override | |
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { | |
Toast.makeText(MainActivity.this, | |
String.valueOf(year) + "/" + | |
String.valueOf(monthOfYear + 1) + "/" + | |
String.valueOf(dayOfMonth), | |
Toast.LENGTH_SHORT).show(); | |
} | |
}, | |
year, month, day); | |
datePickerDialog.show(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment