سؤال

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