java - After Scroll background and images are shuflling in Listview -


when scroll dynamic data shuffling .any way can stop . have tried view holder no luck .my doing wrong . nice .thanks in advance

public view getview(int position, view convertview, viewgroup arg2) {

    textview title, title_sub1, title_sub2, sub1, sub2;         imageview img, lock;     boolean isenable = false;     try     {         if (convertview == null)         {              convertview = relativelayout.inflate(context, r.layout.protection_home, null);          }         int label;         int icon;         if (mfeatures != null)         {             label = mfeatures.get(position).label;             icon = mfeatures.get(position).icon;             isenable = mfeatures.get(position).isenable;         } else         {             label = item[position];             icon = itemimg[position];         }          title = (textview) convertview.findviewbyid(r.id.pro_title);         title_sub1 = (textview) convertview.findviewbyid(r.id.sub_title1);         title_sub2 = (textview) convertview.findviewbyid(r.id.sub_title2);         img = (imageview) convertview.findviewbyid(r.id.icon);         sub1 = (textview) convertview.findviewbyid(r.id.title1_status);         sub2 = (textview) convertview.findviewbyid(r.id.title2_status);         lock = (imageview) convertview.findviewbyid(r.id.lock);         title.settext(label);         img.setimageresource(icon);         title_sub1.settext(setsubtitle1(label));         title_sub2.settext(setsubtitle2(label));          sub1.settext("off");         sub2.settext("on");         if (isenable == false)         {             convertview.setbackgroundresource(r.color.layout_default_bg_color_gray);         } else         {             convertview.setbackgroundresource(r.color.layout_default_bg_color_white);         }         convertview.setid(label);     } catch (exception e)     {         // todo auto-generated catch block         e.printstacktrace();     }      return convertview; } 

use holder , set convertview's tag holder object in else statement

@override     public view getview(int position, view convertview, viewgroup parent) {         textview title, title_sub1, title_sub2, sub1, sub2;         imageview img, lock;         boolean isenable = false;         holder holder = null;          try         {             if (convertview == null)             {                 convertview = relativelayout.inflate(context, r.layout.protection_home, null);                 holder = new holder();                 holder.title = (textview) convertview.findviewbyid(r.id.pro_title);                 holder.title_sub1 = (textview) convertview.findviewbyid(r.id.sub_title1);                 holder.title_sub2 = (textview) convertview.findviewbyid(r.id.sub_title2);                 holder.img = (imageview) convertview.findviewbyid(r.id.icon);                 holder.sub1 = (textview) convertview.findviewbyid(r.id.title1_status);                 holder.sub2 = (textview) convertview.findviewbyid(r.id.title2_status);                 holder.lock = (imageview) convertview.findviewbyid(r.id.lock);                 convertview.settag(holder);              }  else {                 holder = (holder) convertview.gettag();             }              int label;             int icon;             if (mfeatures != null)             {                 label = mfeatures.get(position).label;                 icon = mfeatures.get(position).icon;                 isenable = mfeatures.get(position).isenable;             } else             {                 label = item[position];                 icon = itemimg[position];             }               holder.title.settext(label);             holder.img.setimageresource(icon);             holder.title_sub1.settext(setsubtitle1(label));             holder.title_sub2.settext(setsubtitle2(label));              holder.sub1.settext("off");             holder.sub2.settext("on");             if (isenable == false)             {                 convertview.setbackgroundresource(r.color.layout_default_bg_color_gray);             } else             {                 convertview.setbackgroundresource(r.color.layout_default_bg_color_white);             }             convertview.setid(label);         } catch (exception e)         {             // todo auto-generated catch block             e.printstacktrace();         }          return convertview;     }     } 

Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -