| |
---|
| | EditText titleField = view.findViewById(R.id.todo_title_inputField); |
---|
| | titleField.setText(viwTitle); // 年の初期値を設定 |
---|
| | |
---|
| | NumberPicker numberPickerYear = view.findViewById(R.id.numberPickerYear); |
---|
| | EditText editYearText = (EditText) numberPickerYear.getChildAt(0); |
---|
| | numberPickerYear.setMinValue(citrus.getCurYear()); |
---|
| | numberPickerYear.setMaxValue(citrus.getCurYear() + 30); |
---|
| | numberPickerYear.setValue(viwYear); // 年の初期値を設定 |
---|
| | |
---|
| | NumberPicker numberPickerMonth = view.findViewById(R.id.numberPickerMonth); |
---|
| | EditText editMonthText = (EditText) numberPickerMonth.getChildAt(0); |
---|
| | numberPickerMonth.setMinValue(1); |
---|
| | numberPickerMonth.setMaxValue(12); |
---|
| | numberPickerMonth.setValue(viwMonth); // 月の初期値を設定 |
---|
| | |
---|
| | NumberPicker numberPickerDay = view.findViewById(R.id.numberPickerDay); |
---|
| | EditText editDayText = (EditText) numberPickerDay.getChildAt(0); |
---|
| | numberPickerDay.setMinValue(1); |
---|
| | numberPickerDay.setMaxValue(getDaysInMonth(citrus.getCurYear(), citrus.getCurMonth())); // 日の初期値を設定 |
---|
| | numberPickerDay.setValue(viwDay); // 日の初期値を設定 |
---|
| | |
---|
| | // 年が変更されたとき |
---|
| | numberPickerYear.setOnValueChangedListener((picker, oldVal, newVal) -> { |
---|
| | int month = numberPickerMonth.getValue(); |
---|
| | int daysInMonth = getDaysInMonth(newVal, month); |
---|
| | numberPickerDay.setMaxValue(daysInMonth); |
---|
| | }); |
---|
| | |
---|
| | // 月が変更されたとき |
---|
| | numberPickerMonth.setOnValueChangedListener((picker, oldVal, newVal) -> { |
---|
| | int year = numberPickerYear.getValue(); |
---|
| | int daysInMonth = getDaysInMonth(year, newVal); |
---|
| | numberPickerDay.setMaxValue(daysInMonth); |
---|
| | }); |
---|
| | |
---|
| | // 年が変更されたとき |
---|
| | numberPickerYear.setOnValueChangedListener((picker, oldVal, newVal) -> { |
---|
| | int month = numberPickerMonth.getValue(); |
---|
| | int daysInMonth = getDaysInMonth(newVal, month); |
---|
| | numberPickerDay.setMaxValue(daysInMonth); |
---|
| | }); |
---|
| | |
---|
| | Spinner spinner = view.findViewById(R.id.select_todo_spinner); |
---|
| |
---|
| | calendar.set(Calendar.MONTH, month - 1); // Calendar.MONTHは0から始まるので-1する |
---|
| | return calendar.getActualMaximum(Calendar.DAY_OF_MONTH); |
---|
| | } |
---|
| | |
---|
| | |
---|
| | } |
---|
| | |