title: How to Increment a number, in listView when clicking on Button
body: <p>I'm new to Android, and i'm developing an application where users can like or dislike a post, when the user dislikes the post likes number-- if the user likes number++.</p>
  
  <p>the problem is that when I press the button it works, but it doesn't work for some other items, and when I scroll down or up I lose the info, and it will be mixed all over the other items </p>
  
  <p>I'm using an adapter view for my list view which look like this :</p>
  
  <pre><code>public adapter(Context context, ArrayList&lt;statisticitem&gt; questionaires) {
     super(context, 0, questionaires);
  }
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
  
     final statisticitem c = getItem(position);    
  
  
     if (convertView == null) {
        convertView = LayoutInflater.from(getContext()).inflate(R.layout.custom, parent, false);
  
     }
  
     TextView text1 = (TextView) convertView.findViewById(R.id.textView1);
     final TextView text2 = (TextView) convertView.findViewById(R.id.textView2);
     TextView text3 = (TextView) convertView.findViewById(R.id.textView3);
     ImageView like = (ImageView) convertView.findViewById(R.id.imageView1);
  
  
     text1.setText(c.getIdQuestion());
  
     like.setOnClickListener(new OnClickListener() {
  
          @Override
          public void onClick(View v) {
  
             likes++;
  
             text2.setText("likes :"+likes);
  
  
          }
   });
  
  
  
  
     return convertView;
  }
  
  }
  </code></pre>
  
  
  
  <p>the Main Activity where I have the Listview : </p>
  
  <pre><code>ListView list1 = (ListView) findViewById(R.id.listView1);
    lists  = new ArrayList&lt;statisticitem&gt;();
    for (int i=0;i&lt;10;i++) {  
    statisticitem s = new statisticitem();
    s.setIdQuestion("Question"+i);
    lists.add(s);
    }
  
      adapter adapter = new adapter(MainActivity.this, (ArrayList&lt;statisticitem&gt;) lists);
      list1.setAdapter(adapter);
  
  
  }
  </code></pre>
  
  <p>Using ViewHolder :</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>public class adapter extends ArrayAdapter&lt;statisticitem&gt; {
  
  int likes;
  
  public adapter(Context context, ArrayList&lt;statisticitem&gt; questionaires) {
     super(context, 0, questionaires);
  }
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
     
     final ViewHolder holder;
  
     if (convertView == null) {
        convertView = LayoutInflater.from(getContext()).inflate(R.layout.custom, parent, false);
  
        holder = new ViewHolder();
       holder.text1 = (TextView) convertView.findViewById(R.id.textView1);
       holder.button = (ImageView) convertView.findViewById(R.id.imageView1);
       holder.text2 = (TextView) convertView.findViewById(R.id.textView2); 
       convertView.setTag(holder);
     }
     else {
      holder = (ViewHolder) convertView.getTag();
     }
     
     final statisticitem s = getItem(position); 
   
     if (s !=null)
     {
      holder.text1.setText(s.getIdQuestion());
      
      holder.button.setOnClickListener(new OnClickListener() {
  
        @Override
        public void onClick(View v) {
         likes++;
        holder.text2.setText("yasser"); 
         
        }
       });
      
      
     }
    
  
  
  
  
     return convertView;
  }
  
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>My ViewHolder class :</p>
  
  <pre><code>public class ViewHolder {
  TextView text1;
  TextView text2;
  ImageView button;
  </code></pre>
  
  <p>}</p>
  
  <p>And i'm having always the same problem, can you please suggest me anything, or help me out with this, thanks</p>