android - 如何禁用 DatePickerDialog 的标题?

标签 android android-layout android-dialog android-datepicker

void showDatePickerDailog() {
    Calendar cal = Calendar.getInstance(TimeZone.getDefault());
    DatePickerDialog datePicker = new DatePickerDialog(mContext, datePickerListener,
        cal.get(Calendar.YEAR),
        cal.get(Calendar.MONTH),
        cal.get(Calendar.DAY_OF_MONTH));
    datePicker.setCancelable(false);
    ((ViewGroup) datePicker.getDatePicker()).findViewById(Resources.getSystem().getIdentifier("day", "id", "android")).setVisibility(View.GONE);
    long timeadj = 24*60*60*1000;
    datePicker.getDatePicker().setMinDate((new Date().getTime())+timeadj);
    datePicker.show();
}

我试过上面的代码但是它崩溃了。如何禁用 datepicker header ?

最佳答案

要删除对话框标题,请在 dialog.show() 之前添加以下代码 fragment 。

datePicker.requestWindowFeature(Window.FEATURE_NO_TITLE);

关于android - 如何禁用 DatePickerDialog 的标题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37941917/

相关文章:

android - 如何从图像路径获取资源 ID?

android - WebView 禁用双击

android - 在 Android 中以编程方式刷新时小部件被其他内容替换

AndroidStudio 2.1.1 在 xml 中所做的更改不会在运行时更新

android - android中android :inputType ="textPassword", "textVisiblePassword","textWebPassword"和 "numberPassword"之间的区别?

android - 无法从 NumberPicker 中选择数字

android - 如何使用 glide :3. 6.0 将 GIF 图像从可绘制文件夹加载到 ImageView

android - 折叠工具栏标题消失

android - 为 DialogFragment 选择容器

android - 如何在旋转屏幕后关闭 dialogfragment