我在 Android 应用程序中创建了一个对话框。我想在该对话框中显示图像。但我无法创建图像。请帮助我。 提前致谢 这是我的编码;
public void createbtnteam_adelaide()
{
AlertDialog alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setMessage("What kind of Banner do you Want to Create?");
//我的新代码
ImageView image = (ImageView) alertDialog.findViewById(R.drawable.team_brisbane);
image.setImageResource(R.drawable.team_brisbane);
alertDialog.setButton("Text Only", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// here you can add functions
}
});
alertDialog.setButton2("Text+Image", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// here you can add functions
}
});
alertDialog.show();
}
} 我在 team_gwsid(imageid) 中有小图标。
最佳答案
Android 开发者网站有一篇关于如何在 Android 中创建对话框(包括自定义对话框)的精彩文章。我认为你看一下就可以解决你的问题,这很容易做到。
链接如下:http://developer.android.com/guide/topics/ui/dialogs.html#CustomDialog
顺便说一下(与这个问题无关):我看到您在 StackOverflow 上提出了六个问题,但没有接受任何一个。当有人帮助您解决问题时,您通常会这样做。
关于java - 在Android中如何在对话框中设置图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7347939/