如何把一个图像中的AlertDialog?安卓图像、AlertDialog

由网友(酷似你爹)分享简介:我不知道如何把图像转换为AlertDialog。我有这个code,但我认为这是不可能的。AlertDialog.Builder警报=新AlertDialog.Builder(MessageDemo.this);ImageView的ImageView的=(ImageView的)findViewById(R.id.imag...

我不知道如何把图像转换为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();
 

对话框AlertDialog的使用

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();

阅读全文

相关推荐

最新文章