-1

我有一张图片,我目前正在将它设置在 imageview 上。

我希望当单击 Imageview 时,应该出现一个像对话框一样的弹出窗口,显示图像..任何方法我怎么能做到这一点。

                Context mContext = getApplicationContext();
                Dialog dialog = new Dialog(mContext);

                dialog.setContentView(R.layout.customdialog);
                dialog.setTitle("wateva");

                ImageView ivDialog = (ImageView) dialog.findViewById(R.id.ivDialog);
                String filepath = Environment.getExternalStorageDirectory().getPath();
                folder = new File(filepath,"checking");

                File fa = new File(folder,"bmp1.png");
                Bitmap bmpa = BitmapFactory.decodeFile(fa.getAbsolutePath());
                Log.d("error " , "here");
                ivDialog.setImageBitmap(bmpa);
                dialog.show();
4

1 回答 1

2

为此使用CustomDialog。创建具有Imageview和其他组件的布局并将其设置为Dialog。

Dialog dialog = new Dialog(this);
dialog.setContentView(R.layout.dialoglayout);
ImageView imgView=(ImageView)dialog.findViewById(R.id.imagview);
//set image to imgView
dialog.show();
于 2012-05-29T10:39:25.917 回答