반응형
- A simple dialog containing an DatePicker.
📄 Date Picker Dialog Listener Source Code
// TODO: - DatePickerDialog Listener
private DatePickerDialog.OnDateSetListener onDatePickerListener = new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
monthOfYear++;
final String day = dayOfMonth / 10 == 0 ? "0" + dayOfMonth : Integer.toString(dayOfMonth);
final String month = monthOfYear / 10 == 0 ? "0" + monthOfYear : Integer.toString(monthOfYear);
Toast.makeText(view.getContext(), String.format("%d-%d-%d", year, monthOfYear, dayOfMonth), Toast.LENGTH_SHORT).show();
}
};
📄 Date Picker Dialog Source Code
final Calendar mCurrentTime = Calendar.getInstance();
final DatePickerDialog mDatePickerDialog = new DatePickerDialog(this,
this.onDatePickerListener,
mCurrentTime.get(Calendar.YEAR),
mCurrentTime.get(Calendar.MONTH),
mCurrentTime.get(Calendar.DAY_OF_MONTH)
);
mDatePickerDialog.show();
🚀 REFERENCE
반응형
'#모바일 [Mobile] > Android' 카테고리의 다른 글
[Android - OpenSource] Butter Knife (0) | 2019.07.25 |
---|---|
[Android] Ripple Drawable (버튼 눌림 효과, 물결 효과) (0) | 2019.07.24 |
[Android] Android Studio Assets Folder 만들기 (0) | 2019.06.27 |
[Android] 브로드캐스트 리시버 (Broadcast Receiver) (0) | 2019.06.26 |
[Android] Service (0) | 2019.06.25 |
댓글