【发布时间】:2018-08-01 16:01:23
【问题描述】:
当我将 productQuantity 字符串更改为整数应用程序崩溃时遇到问题,我无法理解错误,但他将我带到这里:
holder.quantity.setText(currentItem.getProductQuantity());
当我投射 setText(currentItem.getProductQuantity()) 时它不起作用
package com.original.original.original.admin;
public class ProductItem {
String productName;
String productCode;
String productBuyPrice;
String productSalePrice;
int productQuantity;
private String key;
public ProductItem() {
}
public ProductItem(String productName, String productCode, String productBuyPrice, String productSalePrice, int productQuantity) {
this.productName = productName;
this.productCode = productCode;
this.productBuyPrice = productBuyPrice;
this.productSalePrice = productSalePrice;
this.productQuantity = productQuantity;
}
// @Exclude
public String getKey() {
return key;
}
// @Exclude
public void setKey(String key) {
this.key = key;
}
public String getProductCode() {
return productCode;
}
public String getProductName() {
return productName;
}
public String getProductBuyPrice() {
return productBuyPrice;
}
public String getProductSalePrice() {
return productSalePrice;
}
public int getProductQuantity() {
return productQuantity;
}
}
还有这个onBindView 方法
@Override
public void onBindViewHolder(productViewHolder holder, int position) {
ProductItem currentItem = items.get(position);
holder.name.setText(currentItem.getProductName());
holder.code.setText(currentItem.getProductCode());
holder.buyPrice.setText(currentItem.getProductBuyPrice());
holder.salePrice.setText(currentItem.getProductSalePrice());
holder.quantity.setText(currentItem.getProductQuantity());
}
【问题讨论】:
-
使用 String.valueOf()
标签: java android firebase android-recyclerview android-viewholder