how can Increase/Decrease Perticular Item quantity in Cart Functionality inside RecyclerView in android : I Have Working on a Cart Items Based Project. In which I have to  Increase/Decrease  Order item Quantity Two Button. EveryThing is Fine But on Perticular Item Increase/Decrease Value it cann't count from 1 .it can get Previous count Value. Here is My Recycler Adapter Code. Please Help me.enter image description here



public class CheckOutAdapter extends RecyclerView.Adapter<CheckOutAdapter.MyVHolder> {

    ArrayList<CartModel> itemsList;
    Context context;
    OnItemClickListner mListner;
    int quantity;


    public CheckOutAdapter(ArrayList<CartModel> itemsList, Context context) {
        this.context = context;
        this.itemsList = itemsList;
    }

    @NonNull
    @Override
    public MyVHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {

        View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.inflator_for_checkoutfrag, parent, false);
        return new MyVHolder(itemView);
    }

    @Override
    public void onBindViewHolder(@NonNull final MyVHolder holder, int position) {
        /*holder.catgry_txt_title.setText(itemsList.get(position).title);
        holder.catgry_img.setImageResource(itemsList.get(position).img);*/
        holder.itemName.setText(itemsList.get(position).CartIteMname);
        holder.itemPartNo.setText(itemsList.get(position).cartItemno);
        holder.finalprice.setText(String.format("%s $", itemsList.get(position).totalprice));

        Picasso.with(context).load(itemsList.get(position).carPart_imgURL).into(holder.itemIMG);

        quantity = Integer.parseInt(itemsList.get(position).cartQuantity);

        if (quantity == 1) {
            holder.txtQuantity.setText(String.valueOf(quantity));
        }
        holder.btnIncrease.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //int count= Integer.parseInt(String.valueOf(holder.txtQuantity.getText()));
                quantity++;
                holder.txtQuantity.setText(String.valueOf(quantity));
             
            }
        });

        holder.btnDecrease.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                int count= Integer.parseInt(String.valueOf(holder.txtQuantity.getText()));

                if (quantity>1)

                quantity--;
                holder.txtQuantity.setText(String.valueOf(quantity));

            }
        });

    }

    @Override
    public int getItemCount() {
        Log.e("adapterLSize",String.valueOf(itemsList.size()));
        return itemsList.size();
    }

    class MyVHolder extends RecyclerView.ViewHolder {
        ImageView itemIMG, removeCart, btnIncrease, btnDecrease;
        TextView cartItemTitle, itemName, itemPartNo, finalprice, txtQuantity;
        LinearLayout addtoCart;
        MyVHolder(View itemView) {
            super(itemView);
            cartItemTitle = itemView.findViewById(R.id.cartItemTitle);
            itemName = itemView.findViewById(R.id.itemName);
            itemPartNo = itemView.findViewById(R.id.itemPartNo);
            finalprice = itemView.findViewById(R.id.finalprice);
            itemIMG = itemView.findViewById(R.id.itemIMG);
            txtQuantity = itemView.findViewById(R.id.txtQuantity);
            btnIncrease = itemView.findViewById(R.id.btnIncrease);
            btnDecrease = itemView.findViewById(R.id.btnDecrease);
            removeCart = itemView.findViewById(R.id.removeCart);
        }

    }

}
