나는 Parcelable로 활동을 통해 데이터를 전달하려고합니다.Android - 소포 : 값을 마샬링 할 수 없습니다.
java.lang.RuntimeException: Parcel: unable to marshal value [email protected]
당신이 문제가 될 수 있습니다 어떤 생각을 가지고 있습니까 :
public class Player implements Parcelable {
public static final Parcelable.Creator<Player> CREATOR = new Parcelable.Creator<Player>() {
public Player createFromParcel(Parcel in) {
return new Player(in);
}
public Player[] newArray(int size) {
return new Player[size];
}
};
private String name;
private List<Card> listCards;
public Player(String namePlayer) {
name = namePlayer;
listCards = new ArrayList<>();
}
private Player(Parcel in) {
// This order must match the order in writeToParcel()
name = in.readString();
in.readList(listCards, null);
// Continue doing this for the rest of your member data
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(name);
dest.writeList(listCards);
}
이 코드를 실행할 때마다, 나는 오류가 발생합니다 : 이것은 내 코드? 당신이 writeList/readList
을 할 수없는 클래스 Parcelable
를 구현하지 않습니다 Card
때문에
감사
카드는 별도의 클래스입니까? 그것은'Parcelable'을 구현합니까? – jitinsharma
실제로 카드는 별도의 클래스이지만 Parcelable을 구현하지 않습니다. –