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.
这篇关于我想将图像从一项活动转移到另一项活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:我想将图像从一项活动转移到另一项活动


- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01