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

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -