【发布时间】:2013-08-23 17:06:20
【问题描述】:
我知道DatePickerDialog 存在很多问题,正如本文Jelly Bean DatePickerDialog --- is there a way to cancel? 中所解释的那样,但我的问题是我只想 显示确认按钮而不是两个按钮。我在DialogFragment 中使用DatePickerDialog,如下所示:
public class DateDialog 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 year = c.get(Calendar.YEAR);
int month = c.get(Calendar.MONTH);
int day = c.get(Calendar.DAY_OF_MONTH);
// set up mindate
minYear = year;
minMonth = month;
minDay = day;
// Create a new custom instance of DatePickerDialog and return it
return new CustomDatePickerDialog(getActivity(), this, year, month, day);
}
}
【问题讨论】:
-
你的意思是删除
Cancel按钮? -
默认系统日期选择器将有两个按钮。如果您只想拥有一个按钮,那么您可以使用自定义日期选择器。