0
私はRealEstateAd
のためにParcelable
インターフェイスを実装しました。しかし、私のデータはアクティビティ間の転送ごとに壊れてしまいます。私はパーセル可能な実装でデータを破損しています
初期データ(活動#に渡される2):
classOfProperty = 101
typeOfAd = 102 <-- Note this value.
typeOfAdvertiser = 101
typeOfProperty = 101
データは、活動#2で受信:
classOfProperty = 101
typeOfAd = 101 <-- It should be 102
typeOfAdvertiser = 101
typeOfProperty = 102 <-- It should be 101
マイParcelable
実装:
// Parcelable implementation
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel out, int flags) {
out.writeString(uid);
out.writeString(id);
out.writeInt(status);
out.writeString(publishDate);
out.writeString(modifiedDate);
out.writeString(expiryData);
out.writeString(publishIp);
out.writeString(modifiedIp);
out.writeString(number);
out.writeInt(rank);
out.writeLong(hits);
out.writeInt(numberOfComments);
out.writeInt(numberOfCreditsUnused);
out.writeInt(numberOfCreditsUsed);
out.writeString(title);
out.writeString(content);
out.writeDouble(price);
out.writeInt(methodOfPayment);
out.writeInt(typeOfAd);
out.writeInt(typeOfProperty);
out.writeInt(typeOfAdvertiser);
out.writeInt(classOfProperty);
out.writeString(mobile);
out.writeString(street);
out.writeString(neighborhood);
out.writeString(city);
out.writeString(province);
out.writeString(country);
out.writeDouble(latitude);
out.writeDouble(longitude);
out.writeInt(numberOfRooms);
out.writeInt(numberOfBaths);
out.writeInt(numberOfHalls);
out.writeInt(numberOfKitchens);
out.writeInt(numberOfFloors);
out.writeInt(numberOfInternalStairs);
out.writeInt(numberOfExternalStairs);
out.writeInt(numberOfSwimmingPools);
out.writeInt(numberOfFireplace);
out.writeInt(numberOfTents);
out.writeInt(numberOfMaidRooms);
out.writeInt(numberOfDriverRooms);
out.writeInt(numberOfStorageRooms);
out.writeInt(numberOfStores);
out.writeInt(numberOfApartments);
out.writeInt(numberOfPalms);
out.writeInt(numberOfWells);
out.writeInt(numberOfGuardRooms);
out.writeInt(hasGarage ? 1 : 0);
out.writeInt(hasCourtyard ? 1 : 0);
out.writeInt(hasFamilySection ? 1 : 0);
out.writeInt(hasSoccerStadium ? 1 : 0);
out.writeInt(hasVolleyballStadium ? 1 : 0);
out.writeInt(hasPlayground ? 1 : 0);
out.writeInt(yearOfConstruction);
out.writeString(floorNumber);
out.writeString(finishing);
out.writeString(area);
out.writeString(lookout);
}
public static final Parcelable.Creator<RealEstateAd> CREATOR = new Parcelable.Creator<RealEstateAd>() {
@Override
public RealEstateAd createFromParcel(Parcel source) {
return new RealEstateAd(source);
}
@Override
public RealEstateAd[] newArray(int size) {
return new RealEstateAd[size];
}
};
private RealEstateAd(Parcel in) {
uid = in.readString();
id = in.readString();
status = in.readInt();
publishDate = in.readString();
modifiedDate = in.readString();
expiryData = in.readString();
publishIp = in.readString();
modifiedIp = in.readString();
number = in.readString();
rank = in.readInt();
hits = in.readInt();
numberOfComments = in.readInt();
numberOfCreditsUnused = in.readInt();
numberOfCreditsUsed = in.readInt();
title = in.readString();
content = in.readString();
price = in.readDouble();
methodOfPayment = in.readInt();
typeOfAd = in.readInt();
typeOfProperty = in.readInt();
typeOfAdvertiser = in.readInt();
classOfProperty = in.readInt();
mobile = in.readString();
street = in.readString();
neighborhood = in.readString();
city = in.readString();
province = in.readString();
country = in.readString();
latitude = in.readDouble();
longitude = in.readDouble();
numberOfRooms = in.readInt();
numberOfBaths = in.readInt();
numberOfHalls = in.readInt();
numberOfKitchens = in.readInt();
numberOfFloors = in.readInt();
numberOfInternalStairs = in.readInt();
numberOfExternalStairs = in.readInt();
numberOfSwimmingPools = in.readInt();
numberOfFireplace = in.readInt();
numberOfTents = in.readInt();
numberOfMaidRooms = in.readInt();
numberOfDriverRooms = in.readInt();
numberOfStorageRooms = in.readInt();
numberOfStores = in.readInt();
numberOfApartments = in.readInt();
numberOfPalms = in.readInt();
numberOfWells = in.readInt();
numberOfGuardRooms = in.readInt();
hasGarage = in.readInt() == 1;
hasCourtyard = in.readInt() == 1;
hasFamilySection = in.readInt() == 1;
hasSoccerStadium = in.readInt() == 1;
hasVolleyballStadium = in.readInt() == 1;
hasPlayground = in.readInt() == 1;
yearOfConstruction = in.readInt();
floorNumber = in.readString();
finishing = in.readString();
area = in.readString();
lookout = in.readString();
}
手書きで書くことができます。おそらくどこかで間違いがあるかもしれません。たとえば、あなたのコードを生成するために、ある種のParceleableジェネレータを使用する必要があります。 http://www.parcelabler.com/。 –