Why possibly you may need to make a button parcelable? Are you suppose
to send it via RPC? It seems like you've chosen a wrong approach for
whatever you trying to do.

On Mar 28, 7:41 pm, Kritzli <pfister.ta...@googlemail.com> wrote:
> Hi,
>
> I've got a problem with a parcelable ArrayList.
> I made a custom Button called MyButton and the ArrayList is a generic
> one. So it only takes MyButton objects.
> Passing the list from on Activity to another is not the problem. In
> the receiving Activity the Log says, it has some elements, but if i
> read specific values (like height and text of the button), it always
> says null or 0.
>
> public class MyButton extends Button implements Parcelable{
>
>     private HashMap<String, String> map;
>     public static Context context;
>
>     public MyButton(Context context){
>         super(context);
>         this.context = context;
>         map = new HashMap<String, String>();
>     }
>
>     public MyButton(Context context, AttributeSet attrs){
>         super(context, attrs);
>     }
>
>     public MyButton(Parcel in){
>         super(context);
>         map = new HashMap<String, String>();
>         readFromParcel(in);
>     }
>
>      public static final Parcelable.Creator<MyButton> CREATOR = new
> Parcelable.Creator<MyButton>() {
>             public MyButton createFromParcel(Parcel in) {
>                 return new MyButton(in);
>             }
>
>             public MyButton[] newArray(int size) {
>                 return new MyButton[size];
>             }
>         };
>
>         @Override
>         public int describeContents() {
>             return 0;
>         }
>
>         @Override
>         public void writeToParcel(Parcel dest, int flags) {
>             dest.writeInt(map.size());
>             for (String s: map.keySet()) {
>                 dest.writeString(s);
>                 dest.writeString(map.get(s));
>             }
>
>         }
>
>         public void readFromParcel(Parcel in) {
>             int count = in.readInt();
>             for (int i = 0; i < count; i++) {
>                 map.put(in.readString(), in.readString());
>             }
>
>         }
>
>         public String get(String key) {
>             return map.get(key);
>         }
>
>         public void put(String key, String value) {
>             map.put(key, value);
>         }
>
>     }
>
> If you could have a look at my code and tell me what i made wrong, I
> would be very glad.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

To unsubscribe from this group, send email to 
android-developers+unsubscribegooglegroups.com or reply to this email with the 
words "REMOVE ME" as the subject.

Reply via email to