Android:Listview row background color changing on scroll -


this code

    public view getdropdownview(int position, view view, viewgroup parent) {          viewholder holder = null;            if(view==null)         {             view= inflater.inflate(r.layout.citylist, parent, false);                    holder=new viewholder();             holder.txttitle = (textview) view.findviewbyid(r.id.tv);                 holder.txttitle.settextsize(typedvalue.complex_unit_dip,db.getsettings().getint(15)-3);             holder.txttitle.setpadding(10, 10, 10, 10);                                  view.settag(holder);                 }         else{                    holder=(viewholder)view.gettag();                }          holder.txttitle.settext(data.get(position));         if(position % 2 == 0)view.setbackgroundcolor(color.rgb(224, 224, 235));         return view;    } 

when scroll color on row appearing on odd row help

the view in list recycled. that's item view scrolled outside screed reused in item scrolled screen. need set odd item normal color this.

if(position % 2 == 0)view.setbackgroundcolor(color.rgb(224, 224, 235)); if(position % 2 == 1)view.setbackgroundcolor(the normal color should set); 

Comments

Popular posts from this blog

html - Difficulties with background-image property -

visual studio code - What does the isShellCommand property actually do and how should you use it? -

ios - Segue not passing data between ViewControllers -