title: How to fix repeating items when scrolling in android listview?
body: <p>I have a custom adapter class which extended by <code>ArrayAdapter</code>. I set the adapter to a <code>listview</code> in my activity. In my <code>objects</code> list I have 8 objects. In the <code>listview</code> shows 5 objects when it's loading(when i'm scrolling the <code>listview</code> it has 3 more data to show). After I scroll the <code>listview</code> last 3 objects are showing same as 1st 3 objects. Here's the code what I tried.</p>
  
  <p><strong>Adapter</strong></p>
  
  <pre><code>@Override
  public View getView(int position, View convertView, ViewGroup parent) {
      if (convertView == null) {
          final MenuItem listItem = objects.get(position);
          holder = new Holder();
          LayoutInflater inflater = (LayoutInflater) this.context
                  .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          convertView = inflater.inflate(R.layout.menu_list_item, parent);
  
          holder.textViewItemName = (TextView) convertView.findViewById(R.id.textViewItemName);
          holder.textViewItemName.setText(listItem.getItemName());
  
          holder.textViewPrice = (TextView) convertView.findViewById(R.id.textViewPrice);
          holder.textViewPrice.setText("$ ".concat(String.valueOf(listItem.getItemPrice())));
  
          holder.imageView = (ImageView) convertView.findViewById(R.id.imageViewItem);
  
  
          holder.buttonPlus = (ButtonRectangle) convertView.findViewById(R.id.buttonPlus);
          holder.cartQtyTextView = (TextView) convertView.findViewById(R.id.textViewCartQty);
  
          // Check &amp; Set
          if (holder.buttonPlus != null) {
              holder.buttonPlus.setOnClickListener(new View.OnClickListener() {
                  @Override
                  public void onClick(View v) {
                      int i = 0;
                      if (holder.cartQtyTextView != null) {
                          holder.cartQtyTextView.setText("" + ++i);
                      }
                  }
              });
          }
          holder.buttonPlus.setBackgroundColor(Color.WHITE);
          holder.buttonPlus.setTextColor(Color.parseColor("#333333"));
  
          holder.buttonMinus = (ButtonRectangle) convertView.findViewById(R.id.buttonMinus);
  
          // Check &amp; Set
          if (holder.buttonMinus != null) {
              holder.buttonMinus.setOnClickListener(new View.OnClickListener() {
                  @Override
                  public void onClick(View v) {
                      int i = 0;
                      if (holder.cartQtyTextView != null) {
                          holder.cartQtyTextView.setText("" + --i);
                      }
                  }
              });
          }
          holder.buttonMinus.setBackgroundColor(Color.WHITE);
          holder.buttonMinus.setTextColor(Color.parseColor("#333333"));
          convertView.setTag(holder);
      } else {
          holder = (Holder) convertView.getTag();
      }
  
      return convertView;
  }
  </code></pre>
  
  <p><strong>Activity</strong></p>
  
  <pre><code>listViweMenu.destroyDrawingCache();
  listViweMenu.setVisibility(ListView.INVISIBLE);
  listViweMenu.setVisibility(ListView.VISIBLE);
  menuListAdapter.notifyDataSetChanged();
  List&lt;uk.co.bapos.android.baposwaiter.data.models.menu.MenuItem&gt; itemsList
              = MenuItemController.fetchAllCategoryItems(this, String.valueOf(new ArrayList&lt;&gt;(menuItemData.entrySet()).get(position).getValue()));
  listDataMenu.clear();
  listDataMenu.addAll(itemsList);
  </code></pre>
  
  <p>How may I fix this?</p>