Android 在ImageView中显示全屏图像

Android 在ImageView中显示全屏图像,android,imageview,parse-platform,Android,Imageview,Parse Platform,单击imageview后,我想在另一个活动上显示全屏图像。我的布局中有6个ImageView,每个ImageView都从解析后端获取图像。如何在获取imagepath时显示图像 public ImageLoader imgl; ImageView ad1,ad2,ad3,ad4,ad5,ad6; List<ParseObject> ob; private ImageView[] imgs = new ImageView[5]; int k=0; ad1=(ImageVi

单击imageview后,我想在另一个活动上显示全屏图像。我的布局中有6个ImageView,每个ImageView都从解析后端获取图像。如何在获取imagepath时显示图像

public ImageLoader imgl;
ImageView ad1,ad2,ad3,ad4,ad5,ad6;   
 List<ParseObject> ob;
 private ImageView[] imgs = new ImageView[5];
 int k=0;

ad1=(ImageView) findViewById(R.id.ad1);
            ad2=(ImageView) findViewById(R.id.ad2);
            ad3=(ImageView) findViewById(R.id.ad3);
            ad4=(ImageView) findViewById(R.id.ad4);
            ad5=(ImageView) findViewById(R.id.ad5);
            ad6=(ImageView) findViewById(R.id.ad6);
             imgs[0] = ad2; 
             imgs[1] = ad3; 
             imgs[2] = ad4; 
             imgs[3] = ad5; 
             imgs[4] = ad6;

                 ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("Adverts");
                 query.orderByDescending("updatedAt");
                 query.whereEqualTo("Status", true);

                 try {
                    ob = query.find();
                     System.out.println("the urls areeee "+ob);
                     for (ParseObject country : ob) {
                         ParseFile image = (ParseFile) country.get("imageFile");
                         imgl.DisplayImage(image.getUrl(), imgs[k]);
                         k=k+1;
                         System.out.println("the urls are"+image.getUrl());
                         pd.dismiss();
                            }
                } catch (com.parse.ParseException e) {
                    // TODO Auto-generated catch block
                    pd.dismiss();
                    e.printStackTrace();
                }

                    ad1.setOnClickListener(new View.OnClickListener() {
                        public void onClick(View view) {
                            Intent ent= new Intent(HomeActivity.this,AdvertsActivity.class);

                            startActivity(ent); 
                    }
                });

            }
公共图像加载程序imgl;
图像视图ad1、ad2、ad3、ad4、ad5、ad6;
列表ob;
私有ImageView[]imgs=新ImageView[5];
int k=0;
ad1=(ImageView)findViewById(R.id.ad1);
ad2=(ImageView)findViewById(R.id.ad2);
ad3=(ImageView)findViewById(R.id.ad3);
ad4=(ImageView)findViewById(R.id.ad4);
ad5=(ImageView)findViewById(R.id.ad5);
ad6=(ImageView)findViewById(R.id.ad6);
imgs[0]=ad2;
imgs[1]=ad3;
imgs[2]=ad4;
imgs[3]=ad5;
imgs[4]=ad6;
ParseQuery=新的ParseQuery(“广告”);
query.orderByDescending(“updatedAt”);
查询:whereEqualTo(“状态”,true);
试一试{
ob=query.find();
System.out.println(“URL是eee”+ob);
用于(对象国家:ob){
ParseFile image=(ParseFile)country.get(“imageFile”);
DisplayImage(image.getUrl(),imgs[k]);
k=k+1;
System.out.println(“URL是”+image.getUrl());
pd.解散();
}
}catch(com.parse.parsee){
//TODO自动生成的捕捉块
pd.解散();
e、 printStackTrace();
}
ad1.setOnClickListener(新视图.OnClickListener(){
公共void onClick(视图){
Intent ent=新的Intent(HomeActivity.this,AdvertsActivity.class);
星触觉;
}
});
}

在ImageView上设置单击侦听器,并在参数和调用方法中传递图像url

    private void viewImage(String url)
    {
        final Dialog nagDialog = new Dialog(ProjectDetailActivity.this,android.R.style.Theme_Translucent_NoTitleBar_Fullscreen);
        nagDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); 
        nagDialog.setCancelable(false);
        nagDialog.setContentView(R.layout.dialog_full_image);
        ivPreview = (ImageView)nagDialog.findViewById(R.id.imageView1);
        BitmapDrawable bmd = (BitmapDrawable)getDrawableFromUrl(url)
        Bitmap bitmap = bmd.getBitmap();
        ivPreview.setImageBitmap(bitmap);
        nagDialog.show();
    }

    public Drawable getDrawableFromUrl(String imgUrl) 
    {
        if(imgUrl == null || imgUrl.equals(""))
            return null;
        try 
        {
            URL url = new URL(imgUrl);
            InputStream in = url.openStream();
            Drawable d = Drawable.createFromStream(in, imgUrl);
            return d;
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
        return null;
    }
使用xml文件

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@android:color/white"
    android:layout_gravity="center" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:contentDescription="@string/hello_world"
        android:src="@android:color/white" 
        android:layout_margin="5dp"
        android:scaleType="centerInside"/>
</RelativeLayout>


谢谢,但如何从url获取位图并设置为“图像视图”?Thanx对于答案,它适用于特定的图像视图和特定的图像。但是,当我在ImageView数组中动态设置图像时,如何为imgs设置图像[5]。因此,当我点击一个特定的ImageView时,我只能得到那个图像。