将图片添加到自定义AlertDialog [英] Adding Image to Custom AlertDialog

查看:1289
本文介绍了将图片添加到自定义AlertDialog的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了一个AlertDialog这也让用户选择的4个选项我显示1。

第3让我们其直接拨打电话,当他们点击和第四之一会显示不同的看法。

这是它的外观现在:

随着第四选项目的不同的任务我想使它看起来不同,因为用户可能会不知所措。

我觉得把一个呼叫图标旁边的第3选择,到第4个选项的箭头旁边的。

现在仍然是我的问题; 如何将我的图像旁的第一个3个选项?

下面是创建对话框中的code:

 公共无效AlarmMenu(){
 最终的CharSequence [] =项目{Politie,救护,Brandweer,提示>};
 AlertDialog.Builder建设者=新AlertDialog.Builder(本);
 builder.setItems(项目,新DialogInterface.OnClickListener(){
     公共无效的onClick(DialogInterface对话,诠释项){
            开关(项目){
                情况下0:
                    打破;
                情况1:
                    打破;
                案例2:
                    打破;
                案例3:
                 打破;
            }
     }
 });
 AlertDialog警报= builder.create();
 alert.show();
}


解决方案

我不认为你可以用AlertBuilder做到这一点。你还是该选择创建以下例如自定义对话框本教程:

http://about-android.blogspot.com/ 2010/02 /创建定制-dialog.html

I made a AlertDialog which let users choose 1 of the 4 options I display.

The first 3 let's them directly call a number when they click it and the 4th one displays a different view.

This is how it looks right now:

As the 4th option purposes a different task I want to make it look different because users can get confused.

I thought of putting an 'call-icon' next to the first 3 option and an arrow next to the 4th option.

Now remains my question; how do I put an image next to the first 3 options?

Here is the code that creates the dialog:

 public void AlarmMenu(){
 final CharSequence[] items = {"Politie", "Ambulance", "Brandweer", "Tips                                   >"};
 AlertDialog.Builder builder = new AlertDialog.Builder(this);
 builder.setItems(items, new DialogInterface.OnClickListener() {
     public void onClick(DialogInterface dialog, int item) {
            switch (item){
                case 0:
                    break;
                case 1:
                    break;
                case 2:
                    break;
                case 3:
                 break;
            }
     }
 });
 AlertDialog alert = builder.create();
 alert.show();
}

解决方案

I dont think that you can do it with an AlertBuilder. You should rather choose to create a custom dialog following e.g. this tutorial:

http://about-android.blogspot.com/2010/02/create-custom-dialog.html

这篇关于将图片添加到自定义AlertDialog的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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