2014-12-02 2 views
0

때 내 동적 데이터를 같이 걸어 갔다. 어떤 식 으로든이 중지 할 수 있습니다. 나는보기 소유자를 또한 시도했다 그러나 운 없음. 나는 어떤 잘못하고있다. 도움이 사전에스크롤 배경 및 이미지 후 목록보기에서 shyflling

공공보기의 getView (INT 위치보기 convertView, 뷰 그룹 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; 
} 
+0

가능한 복제본 http://stackoverflow.com/questions/5635865/images-were-shuffled-when-scrolling-a-listview-with-a-viewholder – JLONG

+0

이 목적으로 발리 라이브러리를 사용해보십시오. Google 또는 Androidhive에서 확인하십시오. 건배! – Rohit

답변

0

사용이 홀더 좋은 .Thanks을하고 다른 문

에 홀더 객체에 convertView의 태그를 설정합니다
@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; 
    } 
    } 
+0

여전히 shuflling – Hii

+0

편집 됨 대답. 죄송합니다. convertView.setTag (holder) 내부가 없습니다. if (convertView == null) {} – vineetv