Model
public class Item implements Parcelable {
private int id;
private String name;
private String brand;
private Integer price;
public Item(int id, String name, String brand, Integer price) {
this.id = id;
this.name = name;
this.brand = brand;
this.price = price;
}
public Item() {
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getBrand() {
return brand;
}
public void setBrand(String brand) {
this.brand = brand;
}
public Integer getPrice() {
return price;
}
public void setPrice(Integer price) {
this.price = price;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(this.id);
dest.writeString(this.name);
dest.writeString(this.brand);
dest.writeValue(this.price);
}
protected Item(Parcel in) {
this.id = in.readInt();
this.name = in.readString();
this.brand = in.readString();
this.price = (Integer) in.readValue(Integer.class.getClassLoader());
}
public static final Parcelable.Creator<Item> CREATOR = new Parcelable.Creator<Item>() {
@Override
public Item createFromParcel(Parcel source) {
return new Item(source);
}
@Override
public Item[] newArray(int size) {
return new Item[size];
}
};
@Override
public String toString() {
return "Item{" +
"id=" + id +
", name='" + name + '\'' +
", brand='" + brand + '\'' +
", price=" + price +
'}';
}
}
Last updated
Was this helpful?