title: how to save rating of rating bar in list view
body: <p>i need help to save the rating of rating bar in my list view for each item.My question is how can i do it because the OnItemClickListener does not work.
  this is how my custom array adapter looks like</p>
  
  <pre><code>public class CustomArrayAdapter extends ArrayAdapter&lt;String&gt; {
  public ArrayList&lt;String&gt; ratings;
  private Activity context;
  private int[] imageID;
  private String[] stdName;
  private double[] GPA;
  private String[] course;
  private String[] rollNo;
  public float cRating;
  
  public CustomArrayAdapter(Activity context, int[] imageID, String[] stdName,    double[] GPA, String[] course, String[] rollNo) {
      super(context, R.layout.row_design, stdName);
      this.context = context;
      this.imageID = imageID;
      this.stdName = stdName;
      this.GPA = GPA;
      this.course = course;
      this.rollNo = rollNo;
  }
  
  static  class ViewContainer
  {
      public ImageView stdImage;
      public ImageView possibleImage;
      public TextView primaryTV;
      public TextView secondryTV;
      public RatingBar ratingBar;
  }
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
  
      ViewContainer viewContainer;
      View rowView = convertView;
     if(rowView == null) {
         //converting the XML file into view objects
         LayoutInflater inflater = context.getLayoutInflater();
         rowView = inflater.inflate(R.layout.row_design, null, true);
         viewContainer = new ViewContainer();
  
         //getting the refrence of widgets
         viewContainer.stdImage = (ImageView) rowView.findViewById(R.id.student_image);
         viewContainer.possibleImage = (ImageView) rowView.findViewById(R.id.possibility_image);
         viewContainer.primaryTV = (TextView) rowView.findViewById(R.id.primary_text_view);
         viewContainer.secondryTV = (TextView) rowView.findViewById(R.id.secondry_text_view);
         viewContainer.ratingBar = (RatingBar) rowView.findViewById(R.id.rating_bar);
  
  
         rowView.setTag(viewContainer);
     } else {
         viewContainer = (ViewContainer) rowView.getTag();
         viewContainer.ratingBar.setRating(0.0f);
         rowView.setBackground(null);
     }
      viewContainer.ratingBar.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {
          @Override
          public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
              cRating = rating;
          }
      });
      //setting the possible values to widgets
      viewContainer.stdImage.setImageResource(imageID[position]);
      viewContainer.primaryTV.setText(stdName[position] + " (GPA:" + GPA[position] + ")");
      viewContainer.secondryTV.setText(course[position] + " (RollNo:" + rollNo[position] + ")");
  
      if (GPA[position] &lt; 3.0) {
          rowView.setBackgroundResource(android.R.color.holo_red_light);
          viewContainer.possibleImage.setImageResource(R.drawable.cross_small);
      } else {
          viewContainer.possibleImage.setImageResource(R.drawable.tick_small);
      }
  
      return rowView;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>and this is my activity where i want to get the rating</p>
  
  <pre><code>public class StudentSelectionActivity extends AppCompatActivity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_student_selection);
      //getting the refrence of list view
      ListView listView = (ListView) findViewById(R.id.list);
      //creating object of Rating activity to access it's public instances
      final MainActivity obj = new MainActivity();
      //creating custom adapter
      final CustomArrayAdapter adapter = new CustomArrayAdapter(this, obj.imageID, obj.stdName, obj.GPA, obj.course, obj.rollNo);
      listView.setAdapter(adapter);
      //handling events  on click listener of list view
      listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
              Toast.makeText(StudentSelectionActivity.this, "rating = " + adapter.cRating, Toast.LENGTH_SHORT).show();
          }
      });
  }
  
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.menu_selected_students, menu);
      return true;
  }
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
      // Handle action bar item clicks here. The action bar will
      // automatically handle clicks on the Home/Up button, so long
      // as you specify a parent activity in AndroidManifest.xml.
      int id = item.getItemId();
  
      //noinspection SimplifiableIfStatement
      if (id == R.id.action_settings) {
          return true;
      }
  
      return super.onOptionsItemSelected(item);
  }
  </code></pre>
  
  <p>}</p>