我想更新列表中的数据并传递到下一个活动
holder.increase.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
redeemQuantityModel.setQuantity(redeemQuantityModel.getQuantity()+1);
quantity++;
price = price + redeemQuantityModel.getPrice();
redeemQuantityModel.setPrice(redeemQuantityModel.getPrice());
Log.d("price", "onClick: "+price);
Log.d("model_price", "onClick: "+redeemQuantityModel.getPrice());
increementInterface.onClick(v,i,quantity,price);
notifyDataSetChanged();
}
});
当用户单击增量并传递数据时,如何更新购物车价格
这是我主动更新列表的地方。
ApiUtil.getServiceClass()。getProductList(URL + _id).enqueue(new Callback(){ @Override public void onResponse(呼叫,响应响应){
if (response.isSuccessful())
{
rotateLoading.stop();
redeemQunResult = response.body();
redeemAddAdapter = new RedeemAddAdapter(RedeemProductScreen.this, redeemQunResult.getRedeemQuantityModels(), new RecyclerViewClickListener() {
@Override
public void onClick(View view, int position) {
}
}, new DecreementInterface() {
@Override
public void onClick(View view, int position,int quantity,int price) {
Log.d("Quant", "onClick: "+quantity);
if (quantity <=0){
row_three.setVisibility(View.GONE);
item_txt.setText("");
txt_price.setText("");
}else {
prices = price;
quantitys = quantity;
row_three.setVisibility(View.VISIBLE);
item_txt.setText(String.valueOf(quantity)+" Item");
txt_price.setText(getApplicationContext().getString(R.string.Rs)+" "+String.valueOf(price));
}
}
}, new IncreementInterface() {
@Override
public void onClick(View view, int position, int quantity,int price) {
Log.d("Quant", "onClick: "+quantity);
prices = price;
quantitys = quantity;
row_three.setVisibility(View.VISIBLE);
item_txt.setText(String.valueOf(quantity)+" Item");
txt_price.setText(getApplicationContext().getString(R.string.Rs)+" "+String.valueOf(price));
}
});
product_recycler.setAdapter(redeemAddAdapter);
redeemAddAdapter.notifyDataSetChanged();
}
}
@Override
public void onFailure(Call<RedeemQunResult> call, Throwable t) {
}
});