我想将图像从一项活动转移到另一项活动 [英] I want to transfer the image from one activity to another

查看:30
本文介绍了我想将图像从一项活动转移到另一项活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须将图像从一项活动转移到另一项活动.在第一个活动中,用户从滚动视图的几个图像中选择图像,并且该图像必须显示在下一个活动的图像视图中.需要帮助.

I have to transfer the image from one activity to another. In first activity the user selects the image out of several images from scroll view and that image has to be displayed in the imageview of next activity. Help required.

推荐答案

在你的第一个Activity中

In your first Activity

将 ImageView 转换为位图

Convert ImageView to Bitmap

    imageView.buildDrawingCache();
    Bitmap bitmap = imageView.getDrawingCache();

    Intent intent = new Intent(this, NewActivity.class);
    intent.putExtra("BitmapImage", bitmap);

在第二个活动中

     Bitmap bitmap = (Bitmap) intent.getParcelableExtra("BitmapImage");

然后在 ImageView 中显示位图.

Then display bitmap in ImageView.

注意:不建议这样做.实际上应该将图像保存在某处并传递路径并从第二个活动中检索.

Note: this is not recommended. Should actually save the image somewhere and pass the path instead and retrieve from second activity.

这篇关于我想将图像从一项活动转移到另一项活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆