Android 日期选择器在 DialogFragment 中显示类似对话框标题的白色视图
Android datepicker showing white view like dialog title in DialogFragment
如何删除 DialogFragment
of DatePickerDialog
中出现的白色视图标题
这是我的 DialogFragment 代码供参考:
public class DatePickerFrgDialog 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);
DatePickerDialog dialog = new DatePickerDialog(getActivity(), this, year, month, day);
// Create a new instance of DatePickerFrgDialog and return it
return dialog;
}
@Override
public void onDateSet(DatePicker view, int year, int month, int day) {
}
如果有人遇到这个问题,请分享解决方案。
试试这个代码:
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Dialog dialog = super.onCreateDialog(savedInstanceState);
// request a dialog without the title
dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
DatePickerDialog date_picker_dialog = new DatePickerDialog(getActivity(), this, year, month, day);
date_picker_dialog.setTitle("");
return dialog;
}
使用:
date_picker_dialog.setTitle("");
或:
date_picker_dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
如何删除 DialogFragment
of DatePickerDialog
这是我的 DialogFragment 代码供参考:
public class DatePickerFrgDialog 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);
DatePickerDialog dialog = new DatePickerDialog(getActivity(), this, year, month, day);
// Create a new instance of DatePickerFrgDialog and return it
return dialog;
}
@Override
public void onDateSet(DatePicker view, int year, int month, int day) {
}
如果有人遇到这个问题,请分享解决方案。
试试这个代码:
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Dialog dialog = super.onCreateDialog(savedInstanceState);
// request a dialog without the title
dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
DatePickerDialog date_picker_dialog = new DatePickerDialog(getActivity(), this, year, month, day);
date_picker_dialog.setTitle("");
return dialog;
}
使用:
date_picker_dialog.setTitle("");
或:
date_picker_dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);