Android-如何将位图列表传递给另一个Activity作为参数 [英] Android - how to pass a List of Bitmap to another Activity as parameter
问题描述
我在一个Activity中有一个位图列表,该列表是通过async方法获得的.现在,我需要将位图列表"传递给另一个活动.
I have a List of Bitmap in an Activity, that i got through async method. Now i need to pass my List of Bitmap to another activity.
这是我尝试的代码,但给我一个错误...
Here is the code i tried, but gives me an error...
List<Bitmap> result = bitmapResult
Intent intent = new Intent(PhotoList.this,ImageSlider.class);
intent.putExtra("bitmapList", result);
startActivity(intent);
这给我一个错误.
Cannot resolve method 'putExtra(java.lang.String, java.util.List<android.graphics.Bitmap>)'
最佳做法是什么?以及如何从新的活动中检索列表?
What is the best practice to do it? And how can i retrive the List from the new Activity?
谢谢.
推荐答案
由于我们不知道您的Bitmap数组有多大,并且有可能会超出分配的意图.理想的方法是将位图作为图像存储在SDCard/手机存储中并获取其Uri.因此,您只需要发送Uri字符串数组,例如.列表< String>
而不是 List< Bitmaps>
Since we are not aware how big is your Bitmap array and could potentially hit the allotted limited of passing over intent. The ideal approach is to store your bitmap as image in your SDCard/Phone storage and gets its Uri. Therefore you only need to send the array of Uri Strings e.g. List<String>
rather than List<Bitmaps>
这篇关于Android-如何将位图列表传递给另一个Activity作为参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!