c# - Edit Text in Custom Listview Adapter Loses Value on Scroll -


i have custom list view adapter edit text changes value on own , if 1 row filled value, gets on other rows also.

here's adapter using system; using system.collections.generic; using system.linq; using system.text; using system.data.sqlclient;

using android.app;  using android.content; using android.os; using android.runtime; using android.util; using android.views; using android.widget;  namespace kites { public class marks  {     // add if need more      public string studentname { get; set; }     public string marksscored { get; set; } } public class markslistviewadapter : baseadapter<marks> {     private list<marks> mstuduentmarks;      private context mcontext;      public markslistviewadapter (context context, list<marks> stud)     {         mstuduentmarks = stud;         mcontext = context;     }      public override int count      {                  {             return mstuduentmarks.count;             //              return mattendence.count;          }     }     public override long getitemid (int position)     {         return position;     }     public override marks this[int position]      {                  {             return mstuduentmarks [position];             //              return mattendence [position];          }     }        public override view getview (int position, view convertview, viewgroup parent)     {         view view = convertview;         if (view == null) // otherwise create new 1             view = layoutinflater.from(mcontext).inflate(resource.layout.listview_marks, null, false);          // set view properties reflect data given row         textview txtstudent = view.findviewbyid<textview>(resource.id.textstudentnameteachermarks);         txtstudent.text = mstuduentmarks[position].studentname;         edittext txtmarks = view.findviewbyid<edittext> (resource.id.edittextteachermarks);         txtmarks.text = mstuduentmarks[position].marksscored;          txtmarks.textchanged += (sender, e) =>          {             mstuduentmarks[position].marksscored = txtmarks.text;         };           return view;     }       } } 

following code can proceed click events element :)

public class homerecycleradapter extends recyclerview.adapter<recyclerview.viewholder> implements view.onclicklistener {   private list<string> mitemlist;  recyclerview mrecyclerview;  context context; homeitemviewholder mhomeitemholder;  public homerecycleradapter(list<string> itemlist) {     mitemlist = itemlist; }   public class homeitemviewholder extends recyclerview.viewholder {      imageview mimage;       public homeitemviewholder(view parent) {         super(parent);          mimage = (imageview) parent.findviewbyid(r.id.image);       }  }  public homerecycleradapter(list<string> itemlist, context context, recyclerview mrecyclerview) {     this.mitemlist = itemlist;     this.context = context;     this.mrecyclerview = mrecyclerview;   }   @override public recyclerview.viewholder oncreateviewholder(viewgroup parent, int viewtype) {     context context = parent.getcontext();      final view view = layoutinflater.from(context).inflate(r.layout.item_home, parent, false);       return new homeitemviewholder(view);  }   @override public void onbindviewholder(recyclerview.viewholder viewholder, final int position) {      mhomeitemholder = (homeitemholder) viewholder;                mhomeitemholder.mimage.setonclicklistener(new view.onclicklistener() {         @override         public void onclick(view v) {              //handle code         }     });  }           public int getbasicitemcount() {     return mitemlist == null ? 0 : mitemlist.size(); }   @override public int getitemcount() {     return getbasicitemcount(); // header  }  

}


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -