1
我想在單擊圖像視圖後在其他活動上顯示全屏圖像。我的佈局中有6個ImageView,每個ImageView都從Parse後端獲取圖像。如何在獲取圖像路徑時顯示圖像?在您的ImageView在ImageView中顯示全屏圖像
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);
}
});
}
謝謝,但如何從URL中的位圖和設置圖像視圖? – addy123
chk編輯答案 –
Thanx爲答案,它適用於特定的imageView和特定的圖像。但是,因爲我正在動態地設置ImageViews數組中的圖像,所以我如何將它設置爲imgs [5]。所以當我點擊一個特定的ImageView時,我只能得到那個圖像。 – addy123