Android tutorial - ratingbar in android - android app development - android studio - android development tutorial
Learn android - android tutorial - Ratingbar in android - android examples - android programs
- 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.
- The smaller RatingBar style ( ratingBarStyleSmall) and the larger indicator-only style (ratingBarStyleIndicator) do not support user interaction and should only be used as indicators.
- When using a RatingBar that supports user interaction, placing widgets to the left or right of the RatingBar is discouraged.
- The number of stars set (via setNumStars(int) or in an XML layout) will be shown when the layout width is set to wrap content (if another layout width is set, the results may be unpredictable).
- The secondary progress should not be modified by the client as it is used internally as the background for a fractionally filled star.
- A rating is the evaluation or assessment of something, in terms of quality, quantity, or some combination of both.
- Rating may also refer to:
- Credit rating, estimating the credit worthiness of an individual, corporation or country
- Fire-resistance rating, the duration for a passive fire protection to withstand a standard fire resistance test
- Naval rating, an enlisted member of a country's Navy not conferred by commission or warrant
- Health care provider ratings
- Performance Rating, in computing, used by AMD
- Ranally city rating, a tool used to classify U.S. cities based on economic function
- Power rating, defined as the highest power input allowed to flow through particular equipment
- Content rating, like the following:
- Web content voting, a system where users rate Web content
- Rating site, website that allows rating
- Reputation system, a score for a set of objects within the community based on a collection of opinions
- Telecommunications rating, the calculated cost of a phone call
- United States presidential approval rating, a polling term which reflects the approval of the President of the United States
1. Rating Bar
- Open “res/layout/main.xml” file,
- add a rating bar component,
- few textviews and a button.
- The rating bar contains many configurable values. In this case, the rating bar contains 4 stars, each increase 1.0 value, so, it contains the minimum of 1.0 (1 star) and maximum value of 4.0 (4 stars). In addition, it made the 2nd star (2.0) selected by default.
- File : res/layout/main.xml
- Inside activity “onCreate()” method,
- attach a listener on rating bar,
- fire when rating value is changed.
- Another listener on button, fire when button is clicked.
- File : MyAndroidAppActivity.java
3. Demo - android emulator - android tutorial
- Run the application.
- Result, 2nd star is selected by default.
- Touch on the 3rd star, rating value is changed,
- display the current selected value in the result (textview).
- Touch on the 1st star,
- click on the submit button, the current selected value is displayed as floating message.