Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 11th, 2012  |  syntax: None  |  size: 0.80 KB  |  hits: 5  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to use RatingBar in my music player i created for android?
  2. RatingBar ratingBar = (RatingBar)view.findViewById(R.id.ratingbar);
  3. RatingBar.OnRatingBarChangeListener barListener =
  4.     new RatingBar.OnRatingBarChangeListener() {
  5.             public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromTouch) {
  6.                 // Do your database stuff here
  7.             }
  8.  
  9.         }
  10.        
  11. //mp is the reference to your media player
  12. mp.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {          
  13.         public void onCompletion(MediaPlayer mp) {
  14.             // Do what you need to do to reset the rating bar. Might need to make a public reference or create a way for this inner class to access the rating bar.
  15.  
  16.         }          
  17.     });
  18.        
  19. ratingbar.setRating(3); //For three stars