如何在对话框中显示图像
此代码将显示带有“Hello World”的对话框,但我想显示一个 像这样的图像: 也在同一个对话框中。
谁能帮助我吗?
private void showDialog(String message)
{
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Hello World");
builder.setCancelable(false);
builder.setPositiveButton("OK", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int id)
{
dialog.dismiss();
}
});
AlertDialog alert = builder.create();
alert.show();
}
This code will display the dialog box with "Hello World" but I want to display an
image like : also in the same dialog box.
can anyone help me?
private void showDialog(String message)
{
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Hello World");
builder.setCancelable(false);
builder.setPositiveButton("OK", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int id)
{
dialog.dismiss();
}
});
AlertDialog alert = builder.create();
alert.show();
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
以下链接将带您访问有关如何执行此操作的教程...
http://developer.android.com/guide/topics/ui/dialogs.html#CustomDialog
尽情享受!
建议:
搜索这个网站你可以找到大部分基本原理
http://developer.android.com
建议:
在编写任何代码之前点击四个时间空格键...它会吸引更多人回答您的问题,因为它看起来写得很好
快乐编码!
Here is the link which will get you to the tutorial about how to do this...
http://developer.android.com/guide/topics/ui/dialogs.html#CustomDialog
Enjoy!
Advice:
Search this website you can find most of basic fundamentals
http://developer.android.com
Suggestion:
HIT four time space bar before writing any code...it will attract more people to answer your question as it will look well written
Happy Coding!
使用CustomDialog而不是默认的。
查看此自定义对话框:http://www.helloandroid。 com/tutorials/how-display-custom-dialog-your-android-application
希望这能解决您的问题。
Use CustomDialog instead of the default one.
Checkout this for customDialog: http://www.helloandroid.com/tutorials/how-display-custom-dialog-your-android-application
Hope this will solve your issue.