姬長信(Redy)

将用户定义对象的arraylist传递给Intent androi…


我试图将arraylist结构传递给如下意图,
在我正在使用的调用函数中
ArrayList s=(ArrayList)msg.obj;                                 
Intent i = new Intent(ReadTasks.this, GenrateTasks.class);                          
i.putExtra("tasks", s);
startActivity(i);

并在被调用的函数中

Bundle b = getIntent().getExtras();
if(b!=null)
{           
    ArrayList as = (ArrayList)b.getSerializable("tasklist");
}

我已经在两个类中给出了可序列化的实现,但是我无法编组…在行启动活动的调用函数中运行时错误.请帮忙怎么办!

编辑1:堆栈跟踪:

04-01 22:21:53.999: E/AndroidRuntime(2078): FATAL EXCEPTION: main
04-01 22:21:53.999: E/AndroidRuntime(2078): java.lang.RuntimeException: Parcel: unable to marshal value com.viralm.readjson.Parliament@413597f0
04-01 22:21:53.999: E/AndroidRuntime(2078):     at android.os.Parcel.writeValue(Parcel.java:1137)
04-01 22:21:53.999: E/AndroidRuntime(2078):     at android.os.Parcel.writeList(Parcel.java:524)
04-01 22:21:53.999: E/AndroidRuntime(2078):     at android.os.Parcel.writeValue(Parcel.java:1097)
04-01 22:21:53.999: E/AndroidRuntime(2078):     at android.os.Parcel.writeMapInternal(Parcel.java:493)
04-01 22:21:53.999: E/AndroidRuntime(2078):     at android.os.Bundle.writeToParcel(Bundle.java:1612)
04-01 22:21:53.999: E/AndroidRuntime(2078):     at android.os.Parcel.writeBundle(Parcel.java:507)
04-01 22:21:53.999: E/AndroidRuntime(2078):     at android.content.Intent.writeToParcel(Intent.java:5846)
04-01 22:21:53.999: E/AndroidRuntime(2078):     at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1606)
04-01 22:21:53.999: E/AndroidRuntime(2078):     at android.app.Instrumentation.execStartActivity(Instrumentation.java:1379)
04-01 22:21:53.999: E/AndroidRuntime(2078):     at android.app.Activity.startActivityForResult(Activity.java:3190)
04-01 22:21:53.999: E/AndroidRuntime(2078):     at android.app.Activity.startActivity(Activity.java:3297)
04-01 22:21:53.999: E/AndroidRuntime(2078):     at com.viralm.readjson.ReadTasks$1.handleMessage(ReadTasks.java:61)
04-01 22:21:53.999: E/AndroidRuntime(2078):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-01 22:21:53.999: E/AndroidRuntime(2078):     at android.os.Looper.loop(Looper.java:137)
04-01 22:21:53.999: E/AndroidRuntime(2078):     at android.app.ActivityThread.main(ActivityThread.java:4340)
04-01 22:21:53.999: E/AndroidRuntime(2078):     at java.lang.reflect.Method.invokeNative(Native Method)
04-01 22:21:53.999: E/AndroidRuntime(2078):     at java.lang.reflect.Method.invoke(Method.java:511)
04-01 22:21:53.999: E/AndroidRuntime(2078):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
04-01 22:21:53.999: E/AndroidRuntime(2078):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
04-01 22:21:53.999: E/AndroidRuntime(2078):     at dalvik.system.NativeStart.main(Native Method)

我的Parliment课程有5个字符串,其中包含了setter和getter!