문제

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