Question

I get a number from database as string. I want to set this number (for example 3 or 4) to a rating bar. But it says rating bar just accepts float variables.

What should I do?

Was it helpful?

Solution

You need to parse that STring to Float.You can do like this->

float rating = Float.parseFloat(string);
ratingBar.setRating(rating);

OTHER TIPS

Use Float.parseFloat, e.g.:

float val = Float.parseFloat("4");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top