我很难弄清楚如何使用 if/else 语句比较两个价格以确定哪个价格较大,哪个价格较小。通过使用箭头来表示它错误:double 不能取消引用就目前而言,每当我编译我的代码时,我都会收到此错误:public class MeetAdapter extends RecyclerView.Adapter<MeetAdapter.ProductViewHolder> { private Context mCtx; private List<Meet> meetList; public MeetAdapter(Context mCtx, List<Meet> meetList) { this.mCtx = mCtx; this.meetList = meetList; } @Override public ProductViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { LayoutInflater inflater = LayoutInflater.from(mCtx); View view = inflater.inflate(R.layout.meat_list_row, null); return new ProductViewHolder(view); } @Override public void onBindViewHolder(ProductViewHolder holder, int position) { Meet meet = meetList.get(position); Picasso.with(mCtx) .load(meet.getUrl_id()) .into(holder.imageViewM); holder.textViewName.setText(meet.getName()); holder.newPrice.setText(String.valueOf(meet.getPrice())); holder.old_price.setText(meet.getOld_price()); holder.textViewDate_id.setText(meet.getDate_id()); } @Override public int getItemCount() { return meetList.size(); } class ProductViewHolder extends RecyclerView.ViewHolder { TextView textViewName, old_price, newPrice, textViewDate_id; ImageView imageViewM, imageViewD; public ProductViewHolder(View itemView) { super(itemView); textViewName = itemView.findViewById(R.id.meat_name); //old_price = itemView.findViewById(R.id.meat_Direction); newPrice = itemView.findViewById(R.id.meat_price); textViewDate_id = itemView.findViewById(R.id.meat_date); imageViewM = itemView.findViewById(R.id.image_meat); } } }}错误
1 回答
素胚勾勒不出你
TA贡献1827条经验 获得超9个赞
对相同类型的变量使用相同的语法:不要混合使用它们。此外,您在不使用适当的转换器的情况下将 a 转换string为 a 。double
oldPrice = itemView.findViewById(R.id.meat_Direction);
newPrice = itemView.findViewById(R.id.meat_price);
...
...
double old_price = Double.parseDouble(oldPrice.getText().toString())
double new_price = Double.parseDouble(newPrice.getText().toString())
然后进行比较。
添加回答
举报
0/150
提交
取消