我知道在这个岗位Jelly Bean DatePickerDialog --- is there a way to cancel?有很多的问题,如DatePickerDialog
解释,但我的问题是,我想仅显示的确认按钮,而不是两个按钮。我在DialogFragment
使用DatePickerDialog
这样的:安卓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'按钮workaraound? –
默认的系统日期选择器将有两个按钮。如果你想只有一个按钮,那么你可以使用自定义日期选择器。 – Hariharan
@StefanoMunarini是的 – mrroboaat