How to pass drawable between activities

2019-01-03 09:43发布

How can I pass an image, drawable type between activities?

I try this:

private Drawable imagen;

Bundle bundle = new Bundle();
bundle.putSerializable("imagen", (Serializable) unaReceta.getImagen());
Intent myIntent = new Intent(v.getContext(), Receta.class);
myIntent.putExtras(bundle);
startActivityForResult(myIntent, 0);

But it reports me an execption:

java.lang.ClassCastException: android.graphics.drawable.BitmapDrawable

7条回答
Animai°情兽
2楼-- · 2019-01-03 10:12

In case you pull those images from web and load them again and again, caching them would be really good option since you'll decrease network traffic and increase loading speed. I suggest using WebImageView from Droid-Fu. Really good solution, used it on some projects and I'm very satisfied with it.

查看更多
登录 后发表回答