2013-03-31 31 views
1

解组例外,我试图通过一个parcelable对象整数的ArrayList,但我得到一个错误,当机器人尝试读取parcelable对象与parcelable

03-31 19:20:12.484: E/AndroidRuntime(21448): Caused by: java.lang.RuntimeException: Parcel [email protected]: Unmarshalling unknown type code 7602291 at offset 192 
03-31 19:20:12.484: E/AndroidRuntime(21448): at android.os.Parcel.readValue(Parcel.java:2032) 
03-31 19:20:12.484: E/AndroidRuntime(21448): at android.os.Parcel.readListInternal(Parcel.java:2235) 
03-31 19:20:12.484: E/AndroidRuntime(21448): at android.os.Parcel.readList(Parcel.java:1531) 

这里是我的parcelable对象

public class Country implements Parcelable { 

    private String name; 
    private int id; 
    private List<Integer> listTest; 


    public Country() { 
      super(); 
      listTest= new ArrayList<Integer>(); 
     } 


    public Country (String name, int id, List <Integer> listTest) { 
     super(); 
     this.name= name; 
     this.id=id; 
     this.listTest= listTest; 
    } 

public Country (Parcel in) { 

     this.name= in.readString(); 
     this.id= in.readInt(); 
     in.readList(listTest,Integer.class.getClassLoader());//error here 

    } 

    //getters,setters 

    public static final Parcelable.Creator<Country > CREATOR = new Parcelable.Creator<Country>() 
      { 
       @Override 
       public Country createFromParcel(Parcel source) 
       { 
        return new Country (source); 
       } 

       @Override 
       public Country [] newArray(int size) 
       { 
       return new Country [size]; 
       } 
      }; 


@Override 
public int describeContents() { 
    // TODO Auto-generated method stub 
    return 0; 
} 

@Override 
public void writeToParcel(Parcel dest, int flags) { 
    dest.writeString(name); 
    dest.writeInt(id); 
    dest.writeList(listTest); 


} 

}

我检查我的列表,它仅包含整数,所以我不知道从哪里

来此错误

非常感谢您的帮助

回答

2

我改变

in.readList(listTest,List.class.getClassLoader()); 

和我没有错误。

+0

我以为我应该把类型的名单。它现在伟大的工程。非常感谢你 – ulquiorra