Declaring Float Value, Get Float Value
I would like to ask If I've problem trying to change my code for lat and lng into float, can anyone guide me with it. previously, it is in string, but now i would like to decalre
Solution 1:
Since you've cluttered your problem with all of your code it's not easy to identify all of the problems with your code, however this seems obvious:
You will need to replace
float lat=Float.parseFloat(KEY_LATITUDE);
with
float lat=Float.parseFloat((String) map.get(KEY_LATITUDE));
Solution 2:
You seem to be quite confused. You need to parse the values into floats from the XML parser. Change this:
float lat=Float.parseFloat(KEY_LATITUDE);
float lng=Float.parseFloat(KEY_LONGITUDE);
To:
float lat=Float.parseFloat(parser.getValue(KEY_LATITUDE));
float lng=Float.parseFloat(parser.getValue(KEY_LONGITUDE));
Otherwise you're just parsing "longitude" and "latitude" into floats which obviously won't work.
Post a Comment for "Declaring Float Value, Get Float Value"