如何把一个图像中的AlertDialog?安卓 [英] How to put an image in an AlertDialog?? Android

查看:118
本文介绍了如何把一个图像中的AlertDialog?安卓的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道如何把图像转换为AlertDialog。

我有这个code,但我认为这是不可能的。

  AlertDialog.Builder警报=新AlertDialog.Builder(MessageDemo.this);

ImageView的ImageView的=(ImageView的)findViewById(R.id.imageView1);

imageView.setImageResource(R.drawable.cw);

alert.setView(ImageView的);

alert.setNeutralButton(在这里!,新DialogInterface.OnClickListener(){
                公共无效的onClick(DialogInterface DLG,诠释sumthin){

                }
            });

alert.show();
 

解决方案

首先创建一个sample.xml中,并在XML中添加ImageView的。

  AlertDialog.Builder alertadd =新AlertDialog.Builder(
                MessageDemo.this);
LayoutInflater厂= LayoutInflater.from(MessageDemo.this);
最终的视图中查看= factory.inflate(R.layout.sample,NULL);
alertadd.setView(视图);
alertadd.setNeutralButton(在这里!,新DialogInterface.OnClickListener(){
                公共无效的onClick(DialogInterface DLG,诠释sumthin){

                }
            });

alertadd.show();
 

i don't know how to put an image into an AlertDialog.

I have this code, but i think this is not possible.

AlertDialog.Builder alert = new AlertDialog.Builder(MessageDemo.this);

ImageView imageView = (ImageView) findViewById(R.id.imageView1);

imageView.setImageResource(R.drawable.cw);

alert.setView(imageView);

alert.setNeutralButton("Here!", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dlg, int sumthin) {

                }
            });

alert.show();

解决方案

first create one sample.xml and add imageview in that xml..

AlertDialog.Builder alertadd = new AlertDialog.Builder(
                MessageDemo.this);
LayoutInflater factory = LayoutInflater.from(MessageDemo.this);
final View view = factory.inflate(R.layout.sample, null);
alertadd.setView(view);
alertadd.setNeutralButton("Here!", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dlg, int sumthin) {

                }
            });

alertadd.show();

这篇关于如何把一个图像中的AlertDialog?安卓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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