0
默認情況下,活動的開始我希望顯示當前日期但明年。我添加了一個,但在啓動時的TextView中,我看到了當前的日期。感謝您的幫助。Android DatePicker下一年
public void chooseDate2(View v) {
new DatePickerDialog(Activity.this, d1,
dateAndTime1.get(Calendar.YEAR) + 1,
dateAndTime1.get(Calendar.MONTH),
dateAndTime1.get(Calendar.DAY_OF_MONTH))
.show();
}
private void updateLabel2() {
tv.setText(fmtDateAndTime.format(dateAndTime1.getTime()));
}
DatePickerDialog.OnDateSetListener d1=new DatePickerDialog.OnDateSetListener() {
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
dateAndTime1.set(Calendar.YEAR, year);
dateAndTime1.set(Calendar.MONTH, monthOfYear);
dateAndTime1.set(Calendar.DAY_OF_MONTH, dayOfMonth);
updateLabel2();
}
};