title: ViewHolder ImageView setVisibility is repeated
body: <p>I have an adapter with the ViewHolder pattern. It has a TextView and an ImageView. I have to do some check with database in the adapter to show the ImageView or not.
  The problem is that is set the visibility to View.VISIBLE also to other ImageView in other positions. I'm sure that my database doesn't contain those data related to those imageview, but only to the one that is correctly set. </p>
  
  <p>Here is my code (I deleted the part of the textview's set because it worked well):</p>
  
  <pre><code>public class ChaptersAdapter extends ArrayAdapter&lt;List&gt; {
      private final Context context;
      private final ArrayList&lt;List&gt; list;
      ViewHolder viewHolder;
      DatabaseHandler dh;
      SQLiteDatabase db;
      ArrayList&lt;BookmarksHandler&gt; bookmarksAL;
  
      public ChaptersAdapter(Context context, ArrayList&lt;List&gt; list) {
          super(context, R.layout.chaptersadapter, list);
  
          this.context = context;
          this.list = list;
      }
  
      static class ViewHolder{
          TextView titolo;
          ImageView imageView;
      }
  
      @Override
      public View getView(int position, View rowView, ViewGroup parent) {
          dh = new DatabaseHandler(context);
          db = dh.getWritableDatabase();
          bookmarksAL = dh.getAllBookmarks(db);
  
          List chapters = getItem(position);
  
          if(rowView==null){
              LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
              rowView = inflater.inflate(R.layout.chaptersadapter, parent, false);
  
              viewHolder = new ViewHolder();
  
              viewHolder.titolo = (TextView) rowView.findViewById(R.id.textView);
              viewHolder.imageView = (ImageView) rowView.findViewById(R.id.imageView);
  
              rowView.setTag(viewHolder);
          }
          else {
              viewHolder = (ViewHolder) rowView.getTag();
          }
  
          for(int i = 0; i&lt;bookmarksAL.size(); i++){
              if(bookmarksAL.get(i).getId_chapter().equals((String)chapters.get(3))){
                  viewHolder.imageView.setVisibility(View.VISIBLE);
              }
          }
  
  
          return rowView;
      }
  }
  </code></pre>
  
  <p>And here is a screen of what i mean:
  <img src="https://i.stack.imgur.com/r8zC3.png" alt="screen viewholder"></p>
  
  <p>Only the imageview with circle has to be added, not the one with X above. If i scroll down the listview, the viewholder set the visibility to visible also to other imageviews that aren't in my database.</p>