title: Android listview like button increase value of textview in adapter
body: <p>I am using custom adapter for managing listview. I have one button and textview at each row. Now I want to add like-dislike functionality at the click of button. But I am facing issue when user scroll the list, it recycle the previous list item and when it comes again , it won't show the like increment in textview.</p>
  
  <p>How to solve this issue? any good example ?</p>
  
  <p>here is adapter code</p>
  
  <pre><code>public class ReviewAdapter extends BaseAdapter {
  
  protected static final String TAG = "ReviewAdapter";
  private Activity activity;
  private ArrayList&lt;HashMap&lt;String, String&gt;&gt; data;
  private static LayoutInflater inflater = null;
  public ImageLoader imageLoader;
  
  
  private HashMap&lt;Integer, Integer&gt; mCountHash;
  
  public ReviewAdapter(Activity a, ArrayList&lt;HashMap&lt;String, String&gt;&gt; d) {
      activity = a;
      data = d;
      inflater = (LayoutInflater) activity
              .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      imageLoader = new ImageLoader(activity.getApplicationContext());
      mCountHash = new HashMap&lt;Integer, Integer&gt;();
  }
  
  @Override
  public int getCount() {
      return data.size();
  }
  
  @Override
  public Object getItem(int position) {
      return position;
  }
  
  @Override
  public long getItemId(int position) {
      return position;
  }
  
  /**
   * 
   * @author
   * 
   */
  public static class ViewReviewHolder {  
      TextView reviewLikeCount;
      TextView reviewLikeText;        
      Button likeBtn;
  }
  
  @Override
  public View getView(final int position, View convertView, ViewGroup parent) {
      View vi = convertView;
      final ViewReviewHolder viewHolder;
      if (vi == null) {
          vi = inflater.inflate(R.layout.review_row, null);
          viewHolder = new ViewReviewHolder();
  
          viewHolder.reviewLikeCount = (TextView) vi
                  .findViewById(R.id.review_total_likes_count);
  
          viewHolder.reviewLikeText = (TextView) vi
                  .findViewById(R.id.review_total_likes_text);
          viewHolder.reviewCommentCount = (TextView) vi
                  .findViewById(R.id.review_total_comment_count);
  
          viewHolder.likeBtn = (Button) vi.findViewById(R.id.review_like_btn);
  
          vi.setTag(viewHolder);
  
      } else {
          viewHolder = (ViewReviewHolder) vi.getTag();
          viewHolder.reviewLikeCount.setText("");     
          viewHolder.reviewLikeText.setVisibility(View.GONE);
  
  
      }
  
      // Like
  
      // likeBtn.setTag(position);
  
      HashMap&lt;String, String&gt; reviewData = new HashMap&lt;String, String&gt;();
      reviewData = data.get(position);
  
      // Setting all values in list view
  
  
      // Like Count
      if (reviewData.get(ListActivityReview.KEY_REVIEW_LIKE_COUNT).isEmpty()) {
          mCountHash.put(position, 0);
      } else {
  
          mCountHash.put(position, Integer.parseInt(reviewData
                  .get(ListActivityReview.KEY_REVIEW_LIKE_COUNT)));
          viewHolder.reviewLikeCount.setText(reviewData
                  .get(ListActivityReview.KEY_REVIEW_LIKE_COUNT));
          viewHolder.reviewLikeCount.setVisibility(View.VISIBLE);
          viewHolder.reviewLikeText.setVisibility(View.VISIBLE);
      }
  
  
      /*
       * viewHolder.reviewLikeCount.setTag(position);
       * viewHolder.likeBtn.setTag(position);
       */
      viewHolder.likeBtn.setOnClickListener(new OnClickListener() {
  
          @Override
          public void onClick(View v) {
  
              Log.d(TAG, "Pos :" + position);
              Log.d(TAG, "value " + mCountHash.get(position));
              viewHolder.reviewLikeCount.setText(String.valueOf(mCountHash
                      .get(position) + 1));
              viewHolder.reviewLikeCount.setVisibility(View.VISIBLE);
              viewHolder.reviewLikeText.setVisibility(View.VISIBLE);              
  
          }
      });
  
      return vi;
  }
  </code></pre>
  
  <p>}</p>