Android RatingBar Widget Tutorial

Android have its native widget ratingbar to perform rating in the mobile application. It is useful for eCommerce application or other application that provide services to the user. RatingBar is very easy to use and perform in the android application. You just need to add the widget in the xml file to display it. In this tutorial, I will teach you some basic on how to use android ratingbar in the mobile application.

Creating a New Project

1. Open Android Studio IDE in your computer.
2. Create a new project and Edit the Application name to “RatingBarExample”.
(Optional) You can edit the company domain or select the suitable location for current project tutorial. Then click next button to proceed.
3. Select Minimum SDK (API 15:Android 4.0.3 (IceCreamSandwich). I choose the API 15 because many android devices currently are support more than API 15. Click Next button.
4. Choose “Empty Activity” and Click Next button
5. Lastly, press finish button.

Edit main_activity.xml layout

This layout will be display the ratingbar ,text and 3 buttons for save rating, add rate and minus rate. You can follow the example below to display it.

Edit MainActivity.java class

In this class, will use the sharedpreference to save the value of ratingbar and you can either click the ratingbar to change the rating or press the plus and minus button.

Run your project

Finally, the simple ratingbar have been implement in your sample project, so you can try it now.

(Android RatingBar Widget)

Source Code

(Visited 647 times, 1 visits today)
Advertisements

Yong Loon Ng

Ng Yong Loon, better known as Kristofer is a software engineer and computer scientist who doubles up as an entrepreneur.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *