What is the difference between getRating() and getProgress()?

Asked

Viewed 118 times

3

According to the documentation getProgress returns the level of progress of the rating bar, while getRating returns the number of stars of the rating bar.

So in general terms getProgress returns a double value while getRating returns an integer value?

2 answers

4

getProgress() should be using when using a Progressbar and getRating() when you use a Ratingbar.
The same applies to setProgress() and setRating().

TL;DR

getProgress() is a class method Progressbar of which Ratingbar drift(extends) indirectly through Absseekbar.

The purpose of Progressbar is to visually indicate the partial "amount" that has already occurred from any processing.
A visual representation whose dimension is proportional to the elapsed "quantity" is used.
This dimension is calculated by relating the minimum and maximum value to the minimum and maximum size of the Progressbar.
By default these values are 0 and 100 and can be changed by the methods setMin() and setMax().
The value of the "quantity" as a result of the process is assigned by setProgress() and obtained by getProgress() which, contrary to what it says, returns int.
The use of the values 0 and 100 provides that the "amount" elapsed is indicated as a percentage.

On the other hand, Ratingbar is used to represent a rating, using stars.
The number of stars to be 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 the ranting is represented by the partial completion of the star.
So, contrary to what you say, the method getRating() returns float.
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, of step and the number of Ratingbar stars.
Despite the methods setProgress(), getProgress() and setMin() are available should not be used when using Ratingbar.

This is a good example of a case where inheritance should not have been used.

  • 1

    "This is a good example of a case where no inheritance should have been used."!

1


It’s the other way around:

The getProgress() returns an integer value, while the getRating() returns a float.

The difference

Although the RatingBar be a subclass of ProgressBar the getProgress is usually used to recover the percentage (int) of a Progressbar, while getRating is used to recover the current star rating (float) of a Ratingbar.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.