title: onRatingChanged not working properly
body: <p>When the RatingBar in my application is changed, I want it to be able to change a text view (a tip value) to certain numbers depending on the current RatingBar value. I have tried this by using the onRatingChanged method, but that doesn't seem to be working. Also, I want the tip value to change based on the RatingBar value, even if the user doesn't touch the ratingbar, because there is a quiz section on my app that changes the ratingbar. I'm sorry if this isn't very clear, it's hard to explain. </p>
  
  <p><strong>What I want:</strong>  </p>
  
  <ol>
  <li>When the user changes the rating bar, change the tip value accordingly, ex. 5 stars -> 20 tip value</li>
  <li>When the ratingbar changes (because the user uses the quiz activity) change the tip value accordingly</li>
  </ol>
  
  <p>Here is my code:</p>
  
  <pre><code>package com.example.tipquiz;
  
  import com.google.ads.AdRequest;
  import com.google.ads.AdView;
  
  import android.app.Activity;
  import android.app.FragmentManager;
  import android.app.FragmentTransaction;
  import android.content.Intent;
  import android.os.Bundle;
  import android.util.Log;
  import android.view.Menu;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.ImageView;
  import android.widget.RatingBar;
  import android.widget.RatingBar.OnRatingBarChangeListener;
  import android.widget.RelativeLayout;
  import android.widget.TextView;
  
  public class MainActivity extends Activity implements OnRatingBarChangeListener {
  
      // Testing Stuff to show the rating value, will need to use later for maths
      static RatingBar rb;
      TextView tipsTV;
  
      private AdView adview;
  
      ImageView greyPlus, greyMinus, greyPlus2, greyMinus2;
  
      TextView peopleDiningTV, peopleDiningTitle;
      float peopleDining = 2;
  
      TextView tipValue;
      float tipValueFloat = 10;
  
      TextView subtotal, total;
      TextView subtotalTitle, totalTitle;
  
      TextView epp, eppTitle;
      Button done;
      ImageView settingsButton;
  
      // Elements for hiding and such
      static RelativeLayout rl;
  
      public static int rating = 3;
  
      // The Image used as the DropDown button, Rotate code below
      ImageView dropDownButton;
  
      Boolean hasRotated = false;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          setContentView(R.layout.activity_main);
          dropDownButton = (ImageView) findViewById(R.id.dropDownButton);
          rb = (RatingBar) findViewById(R.id.ratingBar1);
          rb.setRating(rating);
  
          tipsTV = (TextView) findViewById(R.id.textView2);
  
          tipValue = (TextView) findViewById(R.id.tipText);
  
          greyPlus = (ImageView) findViewById(R.id.greyPlus);
          greyMinus = (ImageView) findViewById(R.id.greyMinus);
  
          greyPlus2 = (ImageView) findViewById(R.id.greyPlus2);
          greyMinus2 = (ImageView) findViewById(R.id.greyMinus2);
  
          peopleDiningTV = (TextView) findViewById(R.id.textViewPeople);
          peopleDiningTitle = (TextView) findViewById(R.id.TextView02);
  
          subtotal = (TextView) findViewById(R.id.subtotalText);
          subtotalTitle = (TextView) findViewById(R.id.subtotalTitle);
  
          total = (TextView) findViewById(R.id.totalText);
          totalTitle = (TextView) findViewById(R.id.totalTitle);
  
          epp = (TextView) findViewById(R.id.eppText);
          eppTitle = (TextView) findViewById(R.id.eppTitle);
  
          done = (Button) findViewById(R.id.buttonDone);
          settingsButton = (ImageView)findViewById(R.id.settingsButton);
  
          greyPlus.setOnClickListener(new OnClickListener() {
              @Override
              public void onClick(View v) {
                  tipValueFloat++;
                  tipValue.setText(tipValueFloat + "%");
              }
          });
          greyMinus.setOnClickListener(new OnClickListener() {
              @Override
              public void onClick(View v) {
                  if (tipValueFloat &gt;= 1) {
                      tipValueFloat--;
                      tipValue.setText(tipValueFloat + "%");
                  }
                  if (tipValueFloat == 0) {
                      tipValue.setText("No Tip.");
                  }
              }
          });
  
          greyPlus2.setOnClickListener(new OnClickListener() {
              @Override
              public void onClick(View v) {
                  peopleDining++;
                  peopleDiningTV.setText(peopleDining + "");
              }
          });
          greyMinus2.setOnClickListener(new OnClickListener() {
              @Override
              public void onClick(View v) {
                  if (peopleDining &gt; 1) {
                      peopleDining--;
                      peopleDiningTV.setText(peopleDining + "");
                  }
              }
          });
  
          // Look up the AdView as a resource and load a request.
          AdView adView = (AdView) this.findViewById(R.id.adView);
          AdRequest adRequest = new AdRequest();
          adView.loadAd(adRequest);
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.main, menu);
          return true;
      }
  
      FragmentManager fm = getFragmentManager();
      QuizFragment qf = new QuizFragment();
  
      public void dropDown(View view) {
          if (hasRotated == false) {
              FragmentTransaction ft = fm.beginTransaction();
              ft.setCustomAnimations(android.R.animator.fade_in,
                      android.R.animator.fade_out);
              dropDownButton.setRotation(90);
              ft.add(R.id.quizFragment, qf);
              ft.show(qf);
              ft.commit();
              hasRotated = true;
  
              // Hiding Elements, so they don't show through the fragment
              tipsTV.setVisibility(View.INVISIBLE);
              greyPlus.setVisibility(View.INVISIBLE);
              greyMinus.setVisibility(View.INVISIBLE);
              tipValue.setVisibility(View.INVISIBLE);
  
              greyPlus2.setVisibility(View.INVISIBLE);
              greyMinus2.setVisibility(View.INVISIBLE);
              peopleDiningTV.setVisibility(View.INVISIBLE);
              peopleDiningTitle.setVisibility(View.INVISIBLE);
  
              subtotal.setVisibility(View.INVISIBLE);
              subtotalTitle.setVisibility(View.INVISIBLE);
              total.setVisibility(View.INVISIBLE);
              totalTitle.setVisibility(View.INVISIBLE);
  
              epp.setVisibility(View.INVISIBLE);
              eppTitle.setVisibility(View.INVISIBLE);
  
              done.setVisibility(View.INVISIBLE);
              settingsButton.setVisibility(View.INVISIBLE);
          } else if (hasRotated == true) {
              FragmentTransaction ft = fm.beginTransaction();
              ft.setCustomAnimations(android.R.animator.fade_out,
                      android.R.animator.fade_out);
              dropDownButton.setRotation(0);
              hasRotated = false;
              ft.remove(qf);
              ft.commit();
  
              // Hiding Elements, so they don't show through the fragment
              tipsTV.setVisibility(View.VISIBLE);
              greyPlus.setVisibility(View.VISIBLE);
              greyMinus.setVisibility(View.VISIBLE);
              tipValue.setVisibility(View.VISIBLE);
  
              greyPlus2.setVisibility(View.VISIBLE);
              greyMinus2.setVisibility(View.VISIBLE);
              peopleDiningTV.setVisibility(View.VISIBLE);
              peopleDiningTitle.setVisibility(View.VISIBLE);
  
              subtotal.setVisibility(View.VISIBLE);
              subtotalTitle.setVisibility(View.VISIBLE);
              total.setVisibility(View.VISIBLE);
              totalTitle.setVisibility(View.VISIBLE);
  
              epp.setVisibility(View.VISIBLE);
              eppTitle.setVisibility(View.VISIBLE);
  
              done.setVisibility(View.VISIBLE);
              settingsButton.setVisibility(View.VISIBLE);
          }
      }
  
      public void openSettings(View view) {
          Intent intent = new Intent(this, SettingsActivity.class);
          startActivity(intent);
      }
  
      @Override
      public void onRatingChanged(RatingBar ratingBar, float rating,
              boolean fromTouch) {
          if(ratingBar.getRating() == 5){
              tipValue.setText(20+"");
          }
      }
  
      public void done(View view) {
          float subtotalCost = Float.parseFloat(subtotal.getText().toString());
          float tip = tipValueFloat / 100;
          float totalCost = (subtotalCost * tip) + subtotalCost;
  
          epp.setText(totalCost / peopleDining + "");
  
          total.setText(totalCost + "");
  
      }
  }
  </code></pre>