将图像添加到自定义AlertDialog [英] Adding Image to Custom AlertDialog
问题描述
我做了一个AlertDialog,让用户选择我显示的4个选项中的1个。
前3个让他们直接打电话一个数字,当他们点击它和第4一个显示不同的视图。
这是现在的样子:
作为第四个选项,我想要做一个不同的任务看起来不一样,因为用户可能会感到困惑。
我想在前3个选项旁边放置一个呼叫图标,第4个选项旁边有一个箭头。 p>
现在仍然是我的问题;
下面是创建对话框的代码:
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();
}
我不认为你可以使用AlertBuilder进行操作您应该选择创建一个自定义对话框。本教程:
http://about-android.blogspot.com/2010/02/create-custom-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屋!