Hi,

I'm trying to send an ArrayList<T> to another activity. The API
reference says this:

public Intent   putExtra  (String  name, Serializable  value)

to put an extra value that is Serializable, and:

public Serializable   getSerializableExtra  (String  name)

To get the Serializable object. Also, we have the class ArrayList that
implements Serializable:

public class ArrayList extends AbstractList<E> implements Serializable
Cloneable List<E> RandomAccess


I added to the ArrayList<HashMap<String,Object>> image buttons and
Strings, e.g.:

ArrayList<HashMap<String,Object>> arraylist =  enw
ArrayList<HashMap<String,Object>>();
HashMap<String,Object> item = new HashMap<String,Object>();
ImageButton imb = new ImageButton();
item.put("an image button", imb);
item.put("a string", "string1");
arraylist.add(item);
intent.putExtra(ToActivity.OPTIONS, arraylist);
startActivity(intent);

It does not say anything about if ImageButton is Serializable or not.
I get this error trying to receive the intent with this line for sure:

ArrayList<HashMap<String,Object>> data;
data = (ArrayList<HashMap<String,Object>>) intent.getSerializableExtra(OPTIONS);

ERROR LOG:
---------------
E/AndroidRuntime(  368): Caused by: java.lang.RuntimeException:
Parcel: unable to marshal value android.widget.imagebut...@43b7f550

E/AndroidRuntime(  368):        at 
android.os.Parcel.writeValue(Parcel.java:1087)

E/AndroidRuntime(  368):        at 
android.os.Parcel.writeMapInternal(Parcel.java:469)

E/AndroidRuntime(  368):        at android.os.Parcel.writeMap(Parcel.java:453)

E/AndroidRuntime(  368):        at 
android.os.Parcel.writeValue(Parcel.java:1022)

E/AndroidRuntime(  368):        at android.os.Parcel.writeList(Parcel.java:500)

E/AndroidRuntime(  368):        at 
android.os.Parcel.writeValue(Parcel.java:1051)

E/AndroidRuntime(  368):        at 
android.os.Parcel.writeMapInternal(Parcel.java:469)

E/AndroidRuntime(  368):        at 
android.os.Bundle.writeToParcel(Bundle.java:1445)

E/AndroidRuntime(  368):        at 
android.os.Parcel.writeBundle(Parcel.java:483)

E/AndroidRuntime(  368):        at
android.content.Intent.writeToParcel(Intent.java:5237)

E/AndroidRuntime(  368):        at
android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1204)

E/AndroidRuntime(  368):        at
android.app.Instrumentation.execStartActivity(Instrumentation.java:1373)

E/AndroidRuntime(  368):        at
android.app.Activity.startActivityForResult(Activity.java:2749)

E/AndroidRuntime(  368):        at
android.app.Activity.startActivity(Activity.java:2855)


Is ImageButton Serializable? Can we send ImageButton with Intents or
do we have to extend and ImageButton to implement Parcelable?

Thanks in advance,
-- 
If you want freedom, compile the source. Get gentoo.

Sebastián Treu
http://labombiya.com.ar

-- 
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

Reply via email to