RecyclerView When scroll down and scroll up wrong value

SaveSave THMember

I have button calculate in Recyclerview when click calculate my program will sum total value but when I scroll down and scroll up my Edittext restore value to begin value Does anyone have any idea?
Sorry I'm bad English

class PurchaseAdapter : RecyclerView.Adapter
    int receivenum = 0;
    double totalcost = 0;
    double totalprice = 0;
    Context context;
    List<OrderDtl> list = new List<OrderDtl>();

    public PurchaseAdapter(Context context, List<OrderDtl> orderDtl)
        this.context = context;
        this.list = orderDtl;

    public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
        View itemView = LayoutInflater.From (parent.Context).
        Inflate(Resource.Layout.list_view_purchase, parent, false);

        PurchaseViewHolder vh = new PurchaseViewHolder(itemView, OnClick);

        return vh;

    public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
        PurchaseViewHolder vh = holder as PurchaseViewHolder;

        vh.txtproduct.Text = list[position].Product;
        vh.txttotal.Text = list[position].TotUnit.ToString();
        vh.dropdown.Text = list[position].recive_num.ToString();
        vh.chkproduct.Checked = list[position].isSelected;

        list[position].recive_num = list[position].TotUnit;

class PurchaseViewHolder : RecyclerView.ViewHolder
    public TextView dropdown { get; set; }
    public TextView txtproduct { get; set; }
    public TextView txttotal { get; set; }
    public TextView btnadditem { get; set; }
    public TextView btnpullitem { get; set; }
    public CheckBox chkproduct { get; set; }

    public PurchaseViewHolder(View itemView, Action<int> listener) : base(itemView)
        dropdown = itemView.FindViewById<TextView>(Resource.Id.dropdown);
        txtproduct = itemView.FindViewById<TextView>(Resource.Id.txtproduct);
        txttotal = itemView.FindViewById<TextView>(Resource.Id.txttotal);
        btnadditem = itemView.FindViewById<TextView>(Resource.Id.btnin);
        btnpullitem = itemView.FindViewById<TextView>(Resource.Id.btnout);
        chkproduct = itemView.FindViewById<CheckBox>(Resource.Id.chkproduct);


  • AcousticMAcousticM USMember

    I already solve this problem by adding this line
    mRecyclerview.SetItemViewCacheSize() in Activity but I have new problem
    if I do not scroll to the last position the position out of view not set value to editText
    how can I inflate all item when activity call adapter file at first time

Sign In or Register to comment.