AlertDialog样式更改

时间:2016-05-05 10:17:27

标签: java android alert android-alertdialog

我正在制作一个需要AlertDialog的应用。当对话框打开时,它看起来像一个Jellybean警报对话框,但是当我将代码粘贴到另一个项目中时,它看起来像一个Lollipop警报对话框。为什么? (我正在使用AlertDialog.Builder解决方案进行对话;如果存在其他解决方案,请说。另外,我正在使用AIDE开发环境进行编程,并且我在设备上安装了Lollipop操作系统。)

3 个答案:

答案 0 :(得分:0)

制作自定义提醒对话框

check this reference:

How to create a Custom Dialog box in android?

答案 1 :(得分:0)

如果使用AppCompact风格

您可以将此行添加到其中

<item name="alertDialogTheme">@style/AppCompatAlertDialogStyle</item>

并在您的代码中 import android.support.v7.app.AlertDialog

AlertDialog.Builder builder =
       new AlertDialog.Builder(this);

答案 2 :(得分:0)

setContentView属性可以使用您的自定义布局

Dialog dialog = new Dialog(this);
dialog.setContentView(R.layout.custom_dialog_layout);