这是我的 Product.javaimport android.os.Parcel;import android.os.Parcelable;public class Product implements Parcelable { private String name; private String detail; private String price; private int photo; public String getName() { return name; } public void setName(String name) { this.name = name; } public String getDetail() { return detail; } public void setDetail(String detail) { this.detail = detail; } public String getPrice() { return price; } public void setPrice(String price) { this.price = price; } public int getPhoto() { return photo; } public void setPhoto(int photo) { this.photo = photo; } @Override public int describeContents() { return 0; } @Override public void writeToParcel(Parcel dest, int flags) { dest.writeString(this.name); dest.writeString(this.detail); dest.writeString(this.price); dest.writeInt(this.photo); } public Product() { } protected Product(Parcel in) { this.name = in.readString(); this.detail = in.readString(); this.photo = in.readInt(); this.price = in.readString(); } public static final Parcelable.Creator<Product> CREATOR = new Parcelable.Creator<Product>() { @Override public Product createFromParcel(Parcel source) { return new Product(source); } @Override public Product[] newArray(int size) { return new Product[size]; } };}
1 回答
繁星点点滴滴
TA贡献1803条经验 获得超3个赞
它在错误日志中指出了问题。
尝试在空对象引用上调用虚拟方法“void android.widget.TextView.setText(java.lang.CharSequence)”
第 58 行这里有些内容为空
holder.tvName.setText(pd.getName()); holder.tvPrice.setText(pd.getPrice()); holder.tvDetail.setText(pd.getDetail());
添加回答
举报
0/150
提交
取消