我知道在這個崗位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