title: Rating bar in android - Reset value
body: <p>I am using rating bar to mark a field as favorite. The user should be able to unmark it some time in future. But once i set it, the on-click listener is not working on that item.</p>
  
  <p>XML code</p>
  
  <pre><code>&lt;RatingBar
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:numStars="1"
  android:stepSize="1"
  android:id="@+id/fav"/&gt;
  </code></pre>
  
  <p>JAVA code</p>
  
  <pre><code>fav.setOnClickListener(new View.OnClickListener(){ //fav is a ratingbar
          public void onClick(View view){
              favRest = !favRest; //A boolean variable which is set/reset each time it is clicked
              if(favRest)
              {   fav.setRating(1.0f);
                  addFav(uname,hotelName);
  
              }
              else{
                  fav.setRating(0.0f);
                  removeFav(uname,hotelName);
  
              }
  
          }
      });
  </code></pre>