我正在努力做到这一点:
问题是包含OnDateSet方法的DatePickerFragment类是静态的,而微调器是非静态的。在OnDateSet方法中我需要将项添加到适配器并调用方法Spinner.setSelection(int i)
public void onDateSet(DatePicker view, int year1, int month1, int day1) {
firstdate = day1 + "/" + month1 + "/" + year1;
addapter.add(firstdate);
Spinner.setSelection(1);
}
任何人都可以帮助我吗? 提前致谢! 菲利普
答案 0 :(得分:0)
全班:
public static class DatePickerFragment extends DialogFragment
implements DatePickerDialog.OnDateSetListener {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// Use the current date as the default date in the picker
final Calendar c = Calendar.getInstance();
int year1 = c.get(Calendar.YEAR)-25;
int month1 = 0;
int day1 = 1;
// Create a new instance of DatePickerDialog and return it
return new DatePickerDialog(getActivity(), this, year1, month1, day1);
}
public void onDateSet(DatePicker view, int year1, int month1, int day1) {
firstdate = day1 + "/" + month1 + "/" + year1;
}
}