如何运用色彩的短信在Android的警告对话框 [英] how to apply color in text message in alert dialog box in android

查看:143
本文介绍了如何运用色彩的短信在Android的警告对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发Android应用程序我使用警告对话框,怎么可以提醒邮件的颜色

I am developing android app i am using alert dialog box how can alert message color

 AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
              builder.setMessage("...........congratulations...........");
                   builder.setCancelable(false)
                .setPositiveButton("Move Next Level",
                        new DialogInterface.OnClickListener() {
                 public void onClick(DialogInterface dialog, int id) 
                                    {


                                    }
                                });

                AlertDialog alert = builder.create();
               alert.setTitle(".");
               alert.setIcon(R.drawable.newmovw);      
                alert.show();   

显示信息,文字怎么能在Android的应用颜色。请提出了一些解决方案。先谢谢了。

Display message, text how can apply color in android. Please forward some solution. Thanks in advance.

提出了一些截图:

http://www.freeimagehosting.net/uploads/a2ae787c70.jpg

推荐答案

您可以创建自定义视图的警告对话框的内容。这是在code。关于<一个解释href="http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/AlertDialogSamples.html"相对=nofollow> APIDemos 自己清楚。检查情况下DIALOG_TEXT_ENTRY 在里面。其背后的类 LayoutInflater 。请检查了。

you can create a custom view to the Alert Dialog Content. which is explained in the code on APIDemos itself clearly. check the case DIALOG_TEXT_ENTRY in it. the class behind it is LayoutInflater. Please check that too.

例如:

LayoutInflater factory = LayoutInflater.from(this);
            final View textEntryView = factory.inflate(R.layout.alert_dialog_text_entry, null);// this layout can created by yourself whatever you want.
            return new AlertDialog.Builder(AlertDialogSamples.this)
                .setIcon(R.drawable.alert_dialog_icon)
                .setTitle(R.string.alert_dialog_text_entry)
                .setView(textEntryView)
                .setPositiveButton(R.string.alert_dialog_ok, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {

                        /* User clicked OK so do some stuff */
                    }
                })
                .setNegativeButton(R.string.alert_dialog_cancel, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {

                        /* User clicked cancel so do some stuff */
                    }
                })
                .create();

希望它帮助。

Hope it helps.

编辑:

layoutname:main.xml中

layoutname : main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <TextView android:layout_width="fill_parent" android:textColor="#663355"
        android:layout_height="wrap_content" android:hint="@string/hello" />
</LinearLayout>

如果布局名为的main.xml ,那么你必须改变code象下面这样:

If the layout name is main.xml then you have to change the code like below:

factory.inflate(R.layout.main, null);

这篇关于如何运用色彩的短信在Android的警告对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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