gpt4 book ai didi

java - 如何将 int 转换为在 textView 内设置

转载 作者:行者123 更新时间:2023-12-01 07:01:03 25 4
gpt4 key购买 nike

当我将 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(YOUR_VALUE);

类似textView.setText(String.valueOf(7));

就你的情况而言,我想,

holder.quantity.setText(String.valueOf(currentItem.getProductQuantity()));

关于java - 如何将 int 转换为在 textView 内设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51637720/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com