gpt4 book ai didi

android DatePickerDialog 只显示一个按钮

转载 作者:太空宇宙 更新时间:2023-11-03 11:37:28 25 4
gpt4 key购买 nike

我知道 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);
}
}

最佳答案

我终于找到了一个更简单的解决方案。这是我的 CustomDatePickerDialog 中的工作区,它扩展了 DatePickerDialog

public CustomDatePickerDialog(Context context, OnDateSetListener callBack, int year, int monthOfYear,int dayOfMonth) {
super(context, callBack, year, monthOfYear, dayOfMonth);
this.setButton(DatePickerDialog.BUTTON_POSITIVE, "OK",this);
this.setButton(DatePickerDialog.BUTTON_NEGATIVE, "",this); // hide cancel button

}

关于android DatePickerDialog 只显示一个按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18355524/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com