Domanda

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?

È stato utile?

Soluzione

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

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

Altri suggerimenti

Use Float.parseFloat, e.g.:

float val = Float.parseFloat("4");
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top