如何删除DialogFragment
<{1>} 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) {
}
如果有人遇到此问题,请分享解决方案。
答案 0 :(得分:2)
试试这段代码:
@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);