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?

Était-ce utile?

La solution

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

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

Autres conseils

Use Float.parseFloat, e.g.:

float val = Float.parseFloat("4");
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top