2017-07-15 86 views
0

我有一個30行數據的RecyclerView。一些行有我得到的圖像,並顯示與畢加索。 問題是,即使那行沒有圖像,圖像框每8行重複一次。 我檢查,如果圖像是空的不要顯示它,但顯示它呢。Android RecyclerView顯示數據甚至不存在

here is an image about it

JobAdapter.java 
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { 
      final MyHolder myHolder = (MyHolder) holder; 
      JobClass current=data.get(position); 
      myHolder.name.setText(current.title); 
      myHolder.manager.setText(current.manager); 
      String phone= (String) new KerashDao(context).JobinfoGetValue(current.job_id.toString(),new KerashDao(context).SettingGetValue("phone").toString()); 
      myHolder.phonecall.setText(phone.toString()); 

      try { 
       if(!current.image.isEmpty()) { 
        Picasso.with(context) 
         .load(current.image) 
         .placeholder(R.drawable.icn_loading) 
         .into(myHolder.picture, new Callback() { 
          @Override 
          public void onSuccess() {myHolder.picture.setVisibility(View.VISIBLE);} 
          @Override 
          public void onError() { 
           myHolder.picture.setVisibility(View.GONE); 
          } 
         }); 
       } 
      }catch (Exception ex){Log.i("JobAdapter2",ex.getMessage().toString()+"");} 

     } 
+0

即使在滾動後,它是否永久保留? – Redman

+0

@Redman。是的,它每8行重複一次。我用'is_empty','equal(「」)'檢查圖像字段。 –

+0

這是什麼設備,它如此之大? – Redman

回答

0

RecyclerView回收表示每行的意見。這意味着一個給定的視圖一旦滾動屏幕就會被另一行重新使用。由於您在某個時間點將圖像加載到該視圖中,因此該圖像會一直存在,直到您清除它爲止。

else條款添加到您的if(!current.image.isEmpty())聲明中,該聲明將清除您的ImageView中的圖像。