I'm working on an application where I have a ListView that shows the coordinates of my smartphone's position previously stored on a database. The rows of the ListView appear to be like: (latitude, longitude), date
.
Is it possible to get the single values of the item? I was thinking to retrieve only the latitude and longitude values of the clicked item so that I can open a new MapsActivity that sets a marker at those specific coordinates.
Looking through other similar questions I've got that with ((TextView) view).getText()
or with listView.getItemAtPosition(position)
I can read the entire content of the item, but I'd like to apply that to the first two values of the ListView.
So for anyone interested I solved my problem by parsing the content of the item as a String by doing like this:
String str = (String) listView.getItemAtPosition(position);
String parts[] = str.split(",");
String lat = parts[0];
String lon = parts[1];
I had to get rid of "(" and ")" in the visualization of the coordinates as they were hindering the string parsing.