'convert a csvLine.split String array into float
I am using android studio for my college work and I have run into a problem when I try to use two parts of a csvLine.split String array for GPS coordinates. I get the error
cannot resolve constructor Geopoint (java.language.string, java.language.string)
How can I convert ids[3] and ids[4] from a string value to a float value?
int i = 0;
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
try {
String csvLine;
while ((csvLine = reader.readLine()) != null) {
ids=csvLine.split(",");
try{
Log.e("CSV file row "+ i, " "+ids[0] + ", " + ids[1]+ ", " + ids[2]+ ", " + ids[3]+ ", " + ids[4]) ;
i++;
// GeoPoint csvGeoPoint = new GeoPoint(ids[3], ids[4]); //The issue is here
// items = new ItemizedIconOverlay<>(this, new ArrayList<OverlayItem>(), markerGestureListener);
// OverlayItem you = new OverlayItem(ids[1], ids[2], (csvGeoPoint));
// items.addItem(you);
// mv.getOverlays().add(items);
}
The line
Log.e("CSV file row "+ i, " "+ids[0] + ", " + ids[1]+ ", " + ids[2]+ ", " + ids[3]+ ", " + ids[4]) ;
Displays these four lines from my csv file. the last two I will use for my geoPoints so that why they would be floats or doubles.
**E/CSV file row 0:** The View, Hotel, A massive hotel, 50.9283421, -1.3928653
**E/CSV file row 1:** TGI Fridays, Restaurant, A lovely place, 50.9050199, -1.4133411
**E/CSV file row 2:** Weather Spoons, Bar, Your average pub, 50.9039012, -1.4078481
**E/CSV file row 3:** Oceania, Club, A huge club, 50.9019739, -1.4161856
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
