AlertDialog.Builder项目背景颜色 [英] AlertDialog.Builder item background color

查看:1367
本文介绍了AlertDialog.Builder项目背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使这三个项目这AlertDialog绿色。问题在于目前绿色背景出现的警报后面和两个项目的不显示绿色。我目前设置AlertDialog的风格与此code:

I'm trying to make the three items of this AlertDialog green. The problem is that currently a green background appears behind the alert, and two of the items do not appear green. I currently set the style of the AlertDialog with this code:

final AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), R.style.ListRow));

在我styles.xml,我有这样的风格:

In my styles.xml, I have this style:

<style name="ListRow">
    <item name="android:background">@color/forest_green</item>
    <item name="android:textSize">18sp</item>
    <item name="android:textColor">@color/dialog_text</item>
</style>

推荐答案

这个工作给我。他们都有后台。

this worked to me. all of them have background.

final AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(this, R.style.ListRow));

builder.setIcon(android.R.drawable.ic_dialog_info).setTitle("welcome")
        .setMessage("...")
        .setPositiveButton("login", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which)
            {
                Intent intent = new Intent(HomeActivity.this, LoginActivity.class);
                startActivity(intent);
            }
        }).setNegativeButton("register", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which)
            {
                Intent intent = new Intent(getApplicationContext(),RegisterActivity.class);
                startActivity(intent);
            }
        }).show();

这篇关于AlertDialog.Builder项目背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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