Вопрос

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?

Это было полезно?

Решение

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

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

Другие советы

Use Float.parseFloat, e.g.:

float val = Float.parseFloat("4");
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top