1

整数の配列リストを使用してパーセル可能なオブジェクトを渡そうとしましたが、アンドロイドがパーセル可能なオブジェクトを読み取ろうとするとエラーが発生しました

 03-31 19:20:12.484: E/AndroidRuntime(21448): Caused by: java.lang.RuntimeException: Parcel android.os.Parcel@4172c410: 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)

これが私のパーセル可能なオブジェクトです

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);


}

}

リストを確認したところ、整数のみが含まれているため、このエラーがどこから来たのかわかりません

ご助力ありがとうございます

4

1 に答える 1

2

I change

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

and I got no error.

于 2013-03-31T19:08:04.247 に答える