简体   繁体   English

Android上的意图-通过ArrayList <Drawable> 去另一个活动

[英]intent on Android - pass ArrayList<Drawable> to another activity

I have two activity and I want to pass ArrayList -> drawablesFromUrl objs from activity A to activity B. Parts of the code is listed as follow: 我有两个活动,我想将ArrayList-> drawablesFromUrl objs从活动A传递到活动B。部分代码如下:

In Activity A: 在活动A中:

Intent i = new Intent(getApplicationContext(),SitePhotoFullScreen.class);
             Bundle myData = new Bundle();
             myData.putInt("id", position);
             myData.putInt("MaxId", imgAdapter.getCount());
             myData.putSerializable("myObjArray",drawablesFromUrl);<---- this objs
             i.putExtras(myData);
             startActivity(i);

In Activity B 在活动B中

ArrayList<Drawable> myObjArray = new ArrayList<Drawable>();    
// get intent data
    Intent i = getIntent();
    Bundle myBundle = i.getExtras();
    position = myBundle.getInt("id");
    MaxId = myBundle.getInt("MaxId");
    myObjArray = (ArrayList<Drawable>) i.getSerializableExtra("myObjArray");

After execute the code, an error occur : 执行代码后,发生错误:

AndroidRuntime(15005): java.lang.RuntimeException: Parcel: unable to marshal value android.graphics.drawable.BitmapDrawable@4052d928

Anyone can help me to solve the problem, thousand thanks! 任何人都可以帮助我解决问题,万分感谢!

Pass your object via Parcelable . 通过Parcelable传递对象。 Here is a link that will show you how to do that with relative ease: 这里的链接将向您展示如何相对轻松地做到这一点:

http://shri.blog.kraya.co.uk/2010/04/26/android-parcel-data-to-pass-between-activities-using-parcelable-classes/ http://shri.blog.kraya.co.uk/2010/04/26/android-parcel-data-to-pass-between-activities-using-parcelable-classes/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android将可通过活动意图绘制的图像传递给第二活动 - Android pass image drawable via intent in activity to 2nd activity 如何使用 android 中的 Parcelable 接口通过意图将包含可绘制参数的 object 传递给另一个活动 - how to pass an object containing with drawable parameter to another activity through intent using Parcelable Interface In android Android:将意图的BasicNameValuePairs的ArrayList传递给另一个Activity - Android:Passing ArrayList of BasicNameValuePairs with intent to another Activity 如何传递按钮意图在另一个活动中制作可绘制的变色? - how to pass button intent to make drawable change color in another activity? 如何使用 android 中的 Intent 将 ArrayList 个对象从一个活动传递到另一个活动? - How to pass ArrayList of Objects from one to another activity using Intent in android? android-无法将Intent中的包裹传递给另一个活动 - android - unable to pass parcelable in Intent to another activity android数据使用intent传递给另一个活动 - android data to pass to another activity using intent 如何使用意图将ArrayList传递给另一个Activity? - How do I pass ArrayList to another Activity using intent? 尝试使用ArrayList创建捆绑 <string> 并通过意图将其传递给另一个活动 - Trying to create bundle with ArrayList<string> and pass it to another activity VIA Intent Android / Eclipse MainActivity将意图传递给另一个活动 - Android/Eclipse MainActivity to pass intent to another activity
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM