我阅读了文档:http : //developer.android.com/guide/topics/ui/controls/pickers.html, 但是现在在棒棒糖中出现了日历(事件可以,但是设置生日很糟糕,我将使用微调模式。)而我无法将其删除!在布局中使用此属性很容易:
<DatePicker
datePickerMode="spinner"...>
但是如果我尝试设置DatePickerDialog的代码
dialogDatePicker.getDatePicker().setSpinnersShown(true);
dialogDatePicker.getDatePicker().setCalendarViewShown(false);
这些属性不起作用,日历继续显示!
public static class MyDatePicker extends DialogFragment implements DatePickerDialog.OnDateSetListener {
int pYear;
int pDay;
int pMonth;
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// Use the current date as the default date in the picker
final Calendar c = Calendar.getInstance();
int year = c.get(Calendar.YEAR);
int month = c.get(Calendar.MONTH);
int day = c.get(Calendar.DAY_OF_MONTH);
DatePickerDialog dialogDatePicker = new DatePickerDialog(getActivity(), this, year, month, day);
dialogDatePicker.getDatePicker().setSpinnersShown(true);
dialogDatePicker.getDatePicker().setCalendarViewShown(false);
return dialogDatePicker;
// Create a new instance of DatePickerDialog and return it
//return new DatePickerDialog(getActivity(), this, year, month, day);
}
public void onDateSet(DatePicker view, int year, int month, int day) {
pYear = year;
pDay = day;
pMonth = month;
}
}
明月笑刀无情
一只斗牛犬
相关分类