-3

In my android app, I have to ask the user to rate it (stars icon, 4 stars). If a user rates 2 stars, I need to convert it as value 2(int type) and store it at back-end (Salesforce).

And also while displaying the summary, I need to get the int value and display as 1,2,3 or 4 stars.

How do I approach this task?

Any help with code or suggestion is appreciated.

Thanks.

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Chid
  • 19
  • 2
  • 12

1 Answers1

1

You can use the RatingBar widget in Android to display a star-rating bar to the user, and then use the getNumStars() method to get the number of stars shown as an int. Details here:

https://developer.android.com/reference/android/widget/RatingBar.html

Joseph Lam
  • 5,289
  • 3
  • 14
  • 13
  • Thanks. It's helpful. Do you know, how can I convert the int value back to stars (rating) while showing it in summary. – Chid Jan 20 '17 at 16:32
  • Sure thing. You can use setNumStars(int numStars) to convert an int value back to stars. – Joseph Lam Jan 20 '17 at 17:13