亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

我的代碼有一些問題,我想在詳細活動中顯示我的產品的價格,但是當我構建我的應用程序時我被強制關閉

我的代碼有一些問題,我想在詳細活動中顯示我的產品的價格,但是當我構建我的應用程序時我被強制關閉

一只萌萌小番薯 2023-07-13 17:43:19
這是我的 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());


查看完整回答
反對 回復 2023-07-13
  • 1 回答
  • 0 關注
  • 121 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號