如何在Android上没有标题栏AlertDialog? (尝试使用requestWindowFeature但没有解析符号)

时间:2017-09-21 03:03:48

标签: android

当我按下Click时,显示AlertDialog。

但点击了按钮,显示标题栏。 我想删除标题栏。所以我试试

builder.requestWindowFeature(Window_FEATURE_NO_TITLE);

requestWindowFeature无法解决符号错误。

Android Dialog: Removing title bar

我引用了这个网站。

但我的来源不起作用。 我的来源不仅仅是活动类。

如何解决这个问题?

3 个答案:

答案 0 :(得分:1)

您可以创建自定义Dialog,并使用is来显示提醒。像下面的东西应该工作

    Dialog dialogView = new Dialog(mActivity, android.R.style.ThemeDeviceDefaultLightNoActionBar);

    dialogView.setContentView(R.layout.custom_alert_layout);
    dialogView.show();

上述内容还可让您进行任何希望显示警报的自定义设置。

答案 1 :(得分:1)

请尝试:

builder.requestWindowFeature (Window_FEATURE_NO_TITLE);

使用此:

builder.supportRequestWindowFeature (Window.FEATURE_NO_TITLE);

答案 2 :(得分:0)

您正在构建器上请求该功能,而不是在对话框上。在构建器上调用requestWindowFeature(Window_FEATURE_NO_TITLE)方法后调用create(),该方法返回AlertDialog,然后调用requestWindowFeature(Window_FEATURE_NO_TITLE)。您应该在设置对话框视图之前请求该功能。您可以在onCreate

对话框的getDialog().requestWindowFeature(Window_FEATURE_NO_TITLE)中请求该功能