필자는 parcelable 클래스를 만들고 싶지만, 변수 중 하나는 또 다른 객체이기 때문에 이것을 관리하는 방법을 모른다.내부에 객체가있는 클래스를 어떻게 분할 할 수 있습니까?
public class CloseItPending implements Parcelable {
@Key
int id;
@Key
CategoryDate date;
@Key
String service;
@Key
String characteristics;
@Key
String buydate;
@Key
String payingmethod;
@Key
String price;
@Key
String others;
@Key
int servicecompanychange;
@Key
int characteristicscompanychange;
@Key
int buydatecompanychange;
@Key
int payingmethodcompanychange;
@Key
int pricecompanychange;
@Key
int otherscompanychange;
@Key
int validate_user;
@Key
int validate_company;
...
두 번째 변수는 date이며 유형은 CategoryDate입니다.
다음 방법은 어떻게되어야합니까?
public int describeContents()
public void writeToParcel(Parcel dest, int flags)
도움 주셔서 감사합니다.
가능성을 다음 CategoryDate
클래스는 당신의 하나입니다
public class CloseItPending implements Parcelable {
@Key
int id;
@Key
CategoryDate date;
@Key
String service;
@Key
String characteristics;
@Key
String buydate;
@Key
String payingmethod;
@Key
String price;
@Key
String others;
@Key
int servicecompanychange;
@Key
int characteristicscompanychange;
@Key
int buydatecompanychange;
@Key
int payingmethodcompanychange;
@Key
int pricecompanychange;
@Key
int otherscompanychange;
@Key
int validate_user;
@Key
int validate_company;
public CloseItPending() {
}
public CloseItPending(Parcel source){
readFromParcel(source);
}
public CloseItPending(int id, CategoryDate date, String service, String characteristics, String buydate, String payingmethod, String price, String others, int servicecompanychange, int characteristicscompanychange, int buydatecompanychange, int payingmethodcompanychange, int pricecompanychange, int otherscompanychange, int validate_user, int validate_company) {
this.id = id;
this.date = date;
this.service = service;
this.characteristics = characteristics;
this.buydate = buydate;
this.payingmethod = payingmethod;
this.price = price;
this.others = others;
this.servicecompanychange = servicecompanychange;
this.characteristicscompanychange = characteristicscompanychange;
this.buydatecompanychange = buydatecompanychange;
this.payingmethodcompanychange = payingmethodcompanychange;
this.pricecompanychange = pricecompanychange;
this.otherscompanychange = otherscompanychange;
this.validate_user = validate_user;
this.validate_company = validate_company;
}
private void readFromParcel(Parcel in) {
this.id = in.readInt();
//Object parcelable too
this.date = in.readParcelable(CategoryDate.class.getClassLoader());
this.service = in.readString();
this.characteristics = in.readString();
this.buydate = in.readString();
this.payingmethod = in.readString();
this.price = in.readString();
this.others = in.readString();
this.servicecompanychange = in.readInt();
this.characteristicscompanychange = in.readInt();
this.buydatecompanychange = in.readInt();
this.payingmethodcompanychange = in.readInt();
this.pricecompanychange = in.readInt();
this.otherscompanychange = in.readInt();
this.validate_user = in.readInt();
this.validate_company = in.readInt();
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public CategoryDate getDate() {
return date;
}
public void setDate(CategoryDate date) {
this.date = date;
}
public String getService() {
return service;
}
public void setService(String service) {
this.service = service;
}
public String getCharacteristics() {
return characteristics;
}
public void setCharacteristics(String characteristics) {
this.characteristics = characteristics;
}
public String getBuydate() {
return buydate;
}
public void setBuydate(String buydate) {
this.buydate = buydate;
}
public String getPayingmethod() {
return payingmethod;
}
public void setPayingmethod(String payingmethod) {
this.payingmethod = payingmethod;
}
public String getPrice() {
return price;
}
public void setPrice(String price) {
this.price = price;
}
public String getOthers() {
return others;
}
public void setOthers(String others) {
this.others = others;
}
public int getServicecompanychange() {
return servicecompanychange;
}
public void setServicecompanychange(int servicecompanychange) {
this.servicecompanychange = servicecompanychange;
}
public int getCharacteristicscompanychange() {
return characteristicscompanychange;
}
public void setCharacteristicscompanychange(int characteristicscompanychange) {
this.characteristicscompanychange = characteristicscompanychange;
}
public int getBuydatecompanychange() {
return buydatecompanychange;
}
public void setBuydatecompanychange(int buydatecompanychange) {
this.buydatecompanychange = buydatecompanychange;
}
public int getPayingmethodcompanychange() {
return payingmethodcompanychange;
}
public void setPayingmethodcompanychange(int payingmethodcompanychange) {
this.payingmethodcompanychange = payingmethodcompanychange;
}
public int getPricecompanychange() {
return pricecompanychange;
}
public void setPricecompanychange(int pricecompanychange) {
this.pricecompanychange = pricecompanychange;
}
public int getOtherscompanychange() {
return otherscompanychange;
}
public void setOtherscompanychange(int otherscompanychange) {
this.otherscompanychange = otherscompanychange;
}
public int getValidate_user() {
return validate_user;
}
public void setValidate_user(int validate_user) {
this.validate_user = validate_user;
}
public int getValidate_company() {
return validate_company;
}
public void setValidate_company(int validate_company) {
this.validate_company = validate_company;
}
@Override
public int describeContents() {
return this.hashCode();
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(id);
//Parcelable object
dest.writeParcelable(date, flags);
dest.writeString(service);
dest.writeString(characteristics);
dest.writeString(buydate);
dest.writeString(payingmethod);
dest.writeString(price);
dest.writeString(others);
dest.writeInt(servicecompanychange);
dest.writeInt(characteristicscompanychange);
dest.writeInt(buydatecompanychange);
dest.writeInt(payingmethodcompanychange);
dest.writeInt(pricecompanychange);
dest.writeInt(otherscompanychange);
dest.writeInt(validate_user);
dest.writeInt(validate_company);
}
유용한 링크 ... [http://stackoverflow.com/questions/7181526/example-of-implementing-parcelable][1] [HTTP : //stackoverflow.com/questions/4049627/parcelable-and-inheritance-in-android][2] [1] : http://stackoverflow.com/questions/7181526/example-of-implementing -parcelable [2] : http://stackoverflow.com/questions/40 49627/parcelable-and-inheritance-in-android –