android.widget.RatingBar.OnRatingBarChangeListener Java Examples

The following examples show how to use android.widget.RatingBar.OnRatingBarChangeListener. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RatingsBarActivity.java    From coursera-android with MIT License 6 votes vote down vote up
@Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
      
      final TextView tv = (TextView) findViewById(R.id.textView);
      final RatingBar bar = (RatingBar) findViewById(R.id.ratingbar);
    
      bar.setOnRatingBarChangeListener(new OnRatingBarChangeListener() {
	
      	// Called when the user swipes the RatingBar
      	@Override
	public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
		tv.setText("Rating:" + rating);
	}
});
  }
 
Example #2
Source File: RatingsBarActivity.java    From coursera-android with MIT License 6 votes vote down vote up
@Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);

      final TextView tv = findViewById(R.id.textView);
      final RatingBar bar = findViewById(R.id.ratingbar);
    
      bar.setOnRatingBarChangeListener(new OnRatingBarChangeListener() {
	
      	// Called when the user swipes the RatingBar
      	@Override
	public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
              tv.setText(getString(R.string.rating_string, rating));
          }
});
  }