diff --git a/app/src/main/java/com/example/citrusclient/views/CreateTodoFragment.java b/app/src/main/java/com/example/citrusclient/views/CreateTodoFragment.java index 2a2ea34..2d63281 100644 --- a/app/src/main/java/com/example/citrusclient/views/CreateTodoFragment.java +++ b/app/src/main/java/com/example/citrusclient/views/CreateTodoFragment.java @@ -130,27 +130,23 @@ 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); // 日の初期値を設定 - // 月が変更されたとき - 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(); @@ -158,6 +154,13 @@ numberPickerDay.setMaxValue(daysInMonth); }); + // 月が変更されたとき + numberPickerMonth.setOnValueChangedListener((picker, oldVal, newVal) -> { + int year = numberPickerYear.getValue(); + int daysInMonth = getDaysInMonth(year, newVal); + numberPickerDay.setMaxValue(daysInMonth); + }); + Spinner spinner = view.findViewById(R.id.select_todo_spinner); bookTitles = new ArrayList<>(); bookTitles.add("本を選択"); @@ -269,4 +272,5 @@ return calendar.getActualMaximum(Calendar.DAY_OF_MONTH); } + } \ No newline at end of file