android - Arrayadapter thinks a list of 45 items only holds 8 repeating items -


i have listview backed custom arrayadapteri wrote. every listview item contains textview , seekbar. idea behind user supposed able move every seekbar , application stores value of seekbar (so seekbars can restored proper values if user exits fragment). these values stored in hashmap key name of competence (aka textview of element)

my issue this: listview holds 45 elements, however, after 8th element, adapter seems think listview @ starting point. example: if move seekbar of 9th element , proceed scroll up, 1st element them have value gave 9th element. listview populated correctly (or seems anyway) though textviews of every element different.

here custom arrayadapter:

public class competencejudgementlistadapter extends arrayadapter<string[]> {  private context mcontext; private arraylist mdata; int mlayoutresourceid; arraylist<competenceitem> mcompetenceitemlist; hashmap<string, integer> valuelist;  public competencejudgementlistadapter(context context, int resource, arraylist<string[]> data) {     super(context, resource, data);     mcontext = context;     this.mlayoutresourceid = resource;     mdata = data;     mcompetenceitemlist = new arraylist<competenceitem>();     valuelist = new hashmap<string, integer>(); }  public arraylist<string[]> getcompetenceitemdata(){     arraylist<string[]> list = new arraylist<string[]>();     for(competenceitem item : mcompetenceitemlist){         string[] data = new string[3];         data[0] = (string) item.title.gettext();         if(valuelist.get(item.competence_id) != null){             data[1] = string.valueof(valuelist.get(item.competence_id).tostring());         }         data[2] = item.competence_id;         list.add(data);     }     return list; }  @override public int getcount() {     return mdata.size(); }  @override public string[] getitem(int position) {     return null; }  @override public long getitemid(int position) {     return 0; }  @override public view getview(final int position, view convertview, viewgroup parent){     view row = convertview;     competenceitem competenceitem = null;     string[] measurementdata = (string[]) mdata.get(position);     string c_title = measurementdata[0];     string c_id = measurementdata[2];     if (row == null) {         layoutinflater inflater = layoutinflater.from(mcontext);         row = inflater.inflate(mlayoutresourceid, parent, false);         competenceitem = new competenceitem();         mcompetenceitemlist.add(competenceitem);         competenceitem.title = (textview) row.findviewbyid(r.id.textview_header_competence_name);         competenceitem.seekbar = (seekbar) row.findviewbyid(r.id.seekbar_competence);         competenceitem.seekbar.setonseekbarchangelistener(new seekbar.onseekbarchangelistener() {             integer newprogress = 0;             string competenceid;              @override             public void onprogresschanged(seekbar seekbar, int progress, boolean fromuser) {              }              private seekbar.onseekbarchangelistener init(string var) {                 competenceid = var;                 return this;             }              @override             public void onstarttrackingtouch(seekbar seekbar) {              }              @override             public void onstoptrackingtouch(seekbar seekbar) {                 newprogress = seekbar.getprogress();                 valuelist.put(competenceid, newprogress);             }         }.init(c_title));         row.settag(competenceitem);      } else {         competenceitem = (competenceitem) row.gettag();     }      competenceitem.title.settext(measurementdata[0]);     competenceitem.competence_id = measurementdata[2];     int max = shareddata.competence_judgement_max_value.getintvalue();     competenceitem.seekbar.setmax(max);     if(measurementdata[1] != null){         string competencevalue = measurementdata[1];         competenceitem.seekbar.setprogress(integer.parseint(competencevalue));     }else{         competenceitem.seekbar.setprogress(0);     }     if((valuelist.get(competenceitem.title.gettext() )!= null)){     competenceitem.seekbar.setprogress(valuelist.get(competenceitem.title.gettext()));     }     return row; }  static class competenceitem{     textview title;     seekbar seekbar;     string competence_id; } 

 if (row == null) {          layoutinflater inflater = layoutinflater.from(mcontext);         row = inflater.inflate(mlayoutresourceid, parent, false);         competenceitem = new competenceitem();         mcompetenceitemlist.add(competenceitem);         competenceitem.title = (textview) row.findviewbyid(r.id.textview_header_competence_name);         competenceitem.seekbar = (seekbar) row.findviewbyid(r.id.seekbar_competence);         row.settag(competenceitem);      } else {         competenceitem = (competenceitem) row.gettag();     }      competenceitem.seekbar.setonseekbarchangelistener(new seekbar.onseekbarchangelistener() {             integer newprogress = 0;             string competenceid;              @override             public void onprogresschanged(seekbar seekbar, int progress, boolean fromuser) {              }              private seekbar.onseekbarchangelistener init(string var) {                 competenceid = var;                 return this;             }              @override             public void onstarttrackingtouch(seekbar seekbar) {              }              @override             public void onstoptrackingtouch(seekbar seekbar) {                 newprogress = seekbar.getprogress();                 valuelist.put(competenceid, newprogress);             }         }.init(c_title)); 

this should work think.since listener same recycled views.


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -