0

我有两个活动,我想将 ArrayList -> drawablesFromUrl objs 从活动 A 传递到活动 B。部分代码如下所示:

在活动 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);

在活动 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");

执行代码后,出现错误:

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

任何人都可以帮助我解决问题,万分感谢!

4

1 回答 1

0

通过传递你的对象Parcelable。这是一个链接,它将向您展示如何相对轻松地做到这一点:

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

于 2012-07-12T03:52:58.343 回答