简体   繁体   中英

pass image-view by ID, convert to bitmap or pass image URL?

I want to pass about 10 images form main activity to other activty. which method is better? converting to bitmap and then pass the pictures,get image id and pass id, using image URL in drawable folder or maybe there is are way. can passing image in bitmap form slow the running of app?

If the images can be found in the drawable folder, better pass the resource ids of those drawables instead. If the images are being downloaded from the internet (eg asynctask) then you pass the bitmaps to another activity. Hope this helps.

If the image is in drawable folder best way is to pass the id.

Example:

Intent i = new Intent(this, DestinationActivity.class);
Bundle b = new Bundle();
b.putInt("FirstImage", R.drawable.nameofyourimage);
i.putExtras(b);
startActivity(i);

and get it in the second activity with getIntent().getExtras()

If the image is on a server, pass the url of the image and download it in the second activity.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM