title: Android ListView repeating items on scrolling
body: <p>I'm working on Android project. one of my activities has inner class ChatHistoryAdapter.
  when activity starts, the list is shown correctly, but after scrolling, some items are duplicated. I've searched for solutions, but almost every solution was to setTag() or Inflater. I think my code is ok with them..
  so I cann't really understand whats the problem here...</p>
  
  <pre><code>private class ChatHistoryAdapter extends BaseAdapter {
      private LayoutInflater inflater;
  
      public ChatHistoryAdapter( LayoutInflater inflater) {
          this.inflater = inflater;
      }
  
      public void newOne() {
          notifyDataSetChanged();
  
      }
  
      @Override
      public int getCount() {
          return messages.size();
      }
  
      @Override
      public Object getItem(int i) {
          return messages.get(i);
      }
  
      @Override
      public long getItemId(int i) {
          return i;
      }
  
      @Override
      public View getView(int position, View myView, ViewGroup vg) {
          MessageHolder messageHolder;
  
          if (myView == null){
              myView = this.inflater.inflate(R.layout.chat_list_item, null, false);
              messageHolder = new MessageHolder();
              messageHolder.hisTxt = (TextView)myView.findViewById(R.id.hisText);
              messageHolder.myTxt = (TextView)myView.findViewById(R.id.myText);
              myView.setTag(messageHolder);
          } else {
              messageHolder = (MessageHolder) myView.getTag();
          }
  
          Message mes = messages.get(position);
  
          if (mes.myMessage()){
                  messageHolder.myTxt.setText(mes.toString());
          } else{
                  messageHolder.hisTxt.setText(mes.toString());
          }
  
          return myView;
      }
  
  }
  
  private static class MessageHolder{
      TextView hisTxt;
      TextView myTxt;
  }
  </code></pre>
  
  <p>here is part where ArrayList is filled:</p>
  
  <pre><code>private void loadMessages() {
      this.messages = new ArrayList&lt;Message&gt;();
      Runnable r = new Runnable() {
  
          @Override
          public void run() {
              messages = dbMes.gettMessages(guest.getId()); // gettMessages is Synchronized
              chatHistoryAdapter = new ChatHistoryAdapter(getLayoutInflater());
              listView.setAdapter(chatHistoryAdapter);
          }
      };
      Thread T = new Thread(r);
      T.start();
  }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/oyl85.jpg" alt="enter image description here"></p>