According to the documentation, getProgress returns the progress bar of the rating bar, while getRating returns the number of stars in the rating bar.
So in general terms getProgress returns a double value while getRating returns an integer value?
According to the documentation, getProgress returns the progress bar of the rating bar, while getRating returns the number of stars in the rating bar.
So in general terms getProgress returns a double value while getRating returns an integer value?
It's the opposite:
getProgress()
returns an integer value, while getRating()
returns a float
.
The difference
AlthoughRatingBar
is a subclass of ProgressBar
getProgress
is usually used to retrieve the percentage (int) of a ProgressBar while getRating
is used to retrieve the current star rating (float) of a RatingBar.
getProgress () should be using when using a ProgressBar and getRating () when using an RatingBar .
The same applies to setProgress()
and setRating()
.
TL; DR
getProgress () is a method of class ProgressBar RatingBar derives indirectly through AbsSeekBar.
The purpose of ProgressBar is to visually indicate the partial "quantity", which has already elapsed, of any processing.
A visual representation is used whose dimension is proportional to the "quantity" elapsed.
This dimension is calculated by relating the minimum and maximum value of the value and the minimum and maximum size of the ProgressBar.
By default these values are 0 and 100, and can be changed using the setMin()
and setMax()
methods.
The value of the "quantity" passed by the process is assigned by setProgress()
and obtained by getProgress()
which, contrary to what it says, returns int.
Using the values 0 and 100 provides that the elapsed "quantity" is indicated as a percentage.
On the other hand, the RatingBar is used to represent a rating using stars.
The number of stars displayed by RatingBar is assigned by setNumStars()
.
Instead of an int, which is used to indicate the progress , a float is used to indicate the ranting .
The use of a float, together with the indication of a step , allows ranting to be represented by the partial filling of the star.
So, contrary to what you say, the method getRating () returns float. Home
Note that the value returned by getRating()
may not be equal to the number of stars filled. This number depends on the maximum value for the rating , the step and the number of stars on the RatingBar.
Although setProgress()
, getProgress()
and setMin()
methods are available they should not be used when using RatingBar.
This is a good example of a case where no inheritance should have been used.