I want to transfer the image from one activity to another(我想将图像从一项活动转移到另一项活动)
问题描述
我必须将图像从一项活动转移到另一项活动.在第一个活动中,用户从滚动视图的几个图像中选择图像,并且该图像必须显示在下一个活动的图像视图中.需要帮助.
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.
这篇关于我想将图像从一项活动转移到另一项活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:我想将图像从一项活动转移到另一项活动
基础教程推荐
- 如何从 logcat 中删除旧数据? 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
