How to Declare a RatingBar

RatingBar was added in API Level 1
A RatingBar is an extension of SeekBar and ProgressBar that shows a rating in stars. The user can touch/drag or use arrow keys to set the rating when using the default size RatingBar.

1. In the file, add the below line to the imports section.

import android.widget.RatingBar;

2. Add the below line to the onCreate method. This will declare a new RatingBar named myRatingBar.

RatingBar myRatingBar;

3. Compile and run!

Next Recommended Article: findViewbyID - How to Find a RatingBar using ID