When choosing a year, a leap check is performed, but all values are lined up by default to the first one entered, then when they change, nothing changes, I understand it is necessary to do something so that when changing the process starts and calculates again, as it is called.
Tell me maybe there is a video course good for Java, I feel floating.
public class MainActivity extends AppCompatActivity { public int maxDay = 31; public int maxYear = 2016; public int minYear = 1940; public int maxMonth = 12; public int minMonth = 1; public int minDay = 1; public int yearChoseInt; public int monthChoseInt = 0; public int modif = 0; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); NumberPicker numberPicker3 = (NumberPicker) findViewById(R.id.numberPicker3); numberPicker3.setMaxValue(maxYear); numberPicker3.setMinValue(minYear); yearChoseInt = numberPicker3.getValue();//получаем значение года // yearChoose = (NumberPicker)findViewById(R.id.numberPicker3); if(yearChoseInt%4==0 && yearChoseInt%100 !=0 || yearChoseInt%400==0){ //проверка високосности года modif = modif+1; } else { modif = 0; } NumberPicker numberPicker2 = (NumberPicker) findViewById(R.id.numberPicker2); numberPicker2.setMaxValue(maxMonth); numberPicker2.setMinValue(minMonth); monthChoseInt = numberPicker2.getValue();//получаем значение месяца // monthChoose = (NumberPicker)findViewById(R.id.numberPicker2); monthChoseInt = numberPicker2.getValue();//получаем значение месяца switch (yearChoseInt) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: maxDay = 31; break; case 4: case 6: case 9: case 11: maxDay = 30; break; case 2: default: maxDay = 28 + modif; } NumberPicker numberPicker = (NumberPicker) findViewById(R.id.numberPicker); numberPicker.setMaxValue(maxDay); numberPicker.setMinValue(minDay); }
}