title: Android ImageAdapter of GridView shows the same (doubled) images
body: <p>My problem is simple: when i click to show GridView (everything is good), then I press back and again click on GridView. Then there are doubled images in GridView. For example, if first time there was 5 photo in GridView, second time there are 10 photos. I think the problem is in my ImageAdapter:</p>
  
  <pre><code>public class ImageAdapter extends BaseAdapter {
  
      private List&lt;Item&gt; items = new ArrayList&lt;Item&gt;();
      private LayoutInflater inflater;
  
      public ImageAdapter(Context context, List&lt;Item&gt; items) {
          inflater = LayoutInflater.from(context);
          this.items = items;
      }
  
      @Override
      public int getCount() {
          return items.size();
      }
  
      @Override
      public Object getItem(int i) {
          return items.get(i);
      }
  
      @Override
      public long getItemId(int i) {
          return items.get(i).drawable;
      }
  
      @Override
      public View getView(int i, View view, ViewGroup viewGroup) {
          View v;
          ImageView picture;
          TextView name;
  
          if (view == null) {
  
              v = inflater.inflate(R.layout.squareimageview, null, false);
              v.setTag(R.id.picture, v.findViewById(R.id.picture));
              v.setTag(R.id.text, v.findViewById(R.id.text));
              picture = (ImageView) v.getTag(R.id.picture);
              name = (TextView) v.getTag(R.id.text);
  
              Item item = (Item) items.get(i);
  
              picture.setImageResource(item.getDrawable());
              name.setText(item.name);
          } else {
              v = view;
              System.out.println("Cia");
          }
  
  
  
          return v;
  
      }
  
  }
  </code></pre>
  
  <p>GridView:</p>
  
  <pre><code>public static List&lt;Item&gt; items = new ArrayList&lt;Item&gt;();
  </code></pre>
  
  <p>...</p>
  
  <pre><code>items.add(new Item("Name1", "Text1", R.drawable.pic_12));
          items.add(new Item("Name2", "Text2", R.drawable.pic_13));
          items.add(new Item("Name3", "Text3", R.drawable.pic_14));
          items.add(new Item("Name4", "Text4", R.drawable.pic_15));
          items.add(new Item("Name5", "Text5", R.drawable.pic_2));
  
          GridView gridView = (GridView) findViewById(R.id.gridview);
          gridView.setAdapter(new ImageAdapter(this, items));
  </code></pre>
  
  <p>Item class:</p>
  
  <pre><code>public class Item {
      String name;
      int drawable;
      String text;
  
      public int getDrawable() {
          return drawable;
      }
  
      public void setDrawable(int drawable) {
          this.drawable = drawable;
      }
  
      public Item(String name, String text, int id) {
          this.name = name;
          this.text = text;
          this.drawable = id;
      }
  
      public String getText() {
          return text;
      }
  
      public void setText(String text) {
          this.text = text;
      }
  
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
  }
  </code></pre>