title: ListView in android not saving ratingBar stars
body: <p>I have a problem with a listView that I made that has a ratingbar and a texview element.Its a very simple program that is meant to displays the list and stores the value of the stars that the user enters into the ratingBar. Unfortunately for some reason when I scroll up and down the rows that go out of the screen, when scrolled back in have their stars changed back to their intial value.The code is below. If anyone could help that would be great. Thanks.</p>
  
  <pre><code>package com.example.test;
  
  import java.util.ArrayList;
  
  import android.app.Activity;
  import android.os.Bundle;
  import android.util.Log;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.ArrayAdapter;
  import android.widget.ListView;
  import android.widget.RatingBar;
  import android.widget.TextView;
  
  public class MainActivity extends Activity implements RatingBar.OnRatingBarChangeListener {
  
  private String[] textList = {"Pikachu","Raichu","Raticate","Ratata","Absol","Abra","Kadabra","Pidgey","Mime","Meowth","Mew","Squirtle","Blastoise","Goop","Kilobyte","Armada"};
  private ArrayList&lt;String&gt; list = new ArrayList&lt;String&gt;();
  ListView listView;
  
  protected void onCreate(Bundle icicle) 
  {
      super.onCreate(icicle);
      setContentView(R.layout.activity_main);
  
      for(int i=0; i&lt;textList.length; i++)
      {
          list.add(i,textList[i]);
      }
  
      listView = (ListView)findViewById(R.id.listRow);
      listView.setAdapter(new setListView(list));
  }
  
  class setListView extends ArrayAdapter&lt;String&gt;
  {
      public setListView(ArrayList&lt;String&gt; list)
      {
          super(MainActivity.this, R.layout.custom_layout, R.id.text, list);
      }
  
      public View getView(int position, View convertView, ViewGroup parent)
      {
          View row = convertView;
  
          if(convertView == null)
          {
              LayoutInflater inflater = getLayoutInflater();
              row = inflater.inflate(R.layout.custom_layout, parent, false);
          }
  
          RatingBar ratingBar = (RatingBar)row.findViewById(R.id.rating);
          RatingBarInfo rating;
          rating = (RatingBarInfo)ratingBar.getTag();
          if(rating == null)
          {
              rating = new RatingBarInfo(position);
              ratingBar.setTag(rating);
          }
          ratingBar.setRating(rating.getRating());
  
          TextView text = (TextView)row.findViewById(R.id.text);
          text.setText(list.get(position));
  
          return(row);
      }
  }
  
  class RatingBarInfo
  {
      float rating;
      int position;
  
      public RatingBarInfo(int positionTemp)
      {
          rating = 2.0f;
          position = positionTemp;
      }
  
      public void setRating(float ratingTemp)
      {
          rating = ratingTemp;
      }
  
      public float getRating()
      {
          return rating;
      }
  
      public int getPosition()
      {
          return position;
      }
  }
  
  public void onRatingChanged(RatingBar ratingBar, float rating,boolean fromUser) 
  {
      RatingBarInfo ratingChange = (RatingBarInfo)ratingBar.getTag();
      ratingChange.setRating(rating);
      ratingBar.setTag(ratingChange);
      ((ArrayAdapter&lt;String&gt;)listView.getAdapter()).notifyDataSetChanged();
  }
  }
  </code></pre>