如何设置AlertDialog的主题 [英] How to set the theme of an AlertDialog

查看:196
本文介绍了如何设置AlertDialog的主题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设置警报的主题,以标准的Andr​​oid主题之一怎么办?我想用全息暗,因为弹出默认为全息光。
我的code:

  AlertDialog.Builder确认=新AlertDialog.Builder(本);
        confirm.setTitle(确认);
        confirm.setMessage(确认并设定延时?);
        confirm.setCancelable(假);
        confirm.setPositiveButton(是,新DialogInterface.OnClickListener(){
               公共无效的onClick(DialogInterface对话,诠释的id){
                    startDelay所();
               }
           });
        confirm.setNegativeButton(否,新DialogInterface.OnClickListener(){
               公共无效的onClick(DialogInterface对话,诠释的id){
                    dialog.cancel();
               }
           });
        confirm.show();


解决方案

您可以在一个构造函数传递一个主题。

 新AlertDialog.Builder(这一点,AlertDialog.THEME_HOLO_DARK)

How do I set the theme of an alert to one of the standard Android themes? I want to use Holo Dark, since the popup defaults to Holo Light. My code:

        AlertDialog.Builder confirm = new AlertDialog.Builder(this);
        confirm.setTitle("Confirm");
        confirm.setMessage("Confirm and set delay?");
        confirm.setCancelable(false);
        confirm.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
               public void onClick(DialogInterface dialog, int id) {
                    startDelay();
               }
           });
        confirm.setNegativeButton("No", new DialogInterface.OnClickListener() {
               public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
               }
           });
        confirm.show();

解决方案

You can a pass a theme in the constructor.

new AlertDialog.Builder (this, AlertDialog.THEME_HOLO_DARK)

这篇关于如何设置AlertDialog的主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆