You need to use the Geocoder class to get the Address from the String. Have a look at this answer:
How can i cast a EditText into an Address? [closed]
-
19-07-2023 - |
Domanda
I'm trying to get a cast of an Address on a EditText.
There is not syntax errors, but the LogCat throws a casting error message, and it doesn't work.
geoPoint((Address)direction.getText()); // this is the cast
Where direction
is an EditText
, and geoPoint()
is defined like this:
public static GeoPoint geoPoint(Address direction){
geoPoint = new GeoPoint(direction.getLongitude(), direction.getLatitude());
return geoPoint;
}
The idea is to get the coordinates of a postal address
Thanks in advance!
Soluzione
Altri suggerimenti
Nope! As you can see on the docs, Address has nothing to do with EditText. You can only 'cast' on objects from the same class hierarchy. There's another similar question on this subject you may refer to: Casting objects in Java
What you can do is take the 'String' value of the Address and put it in the EditText using the
EditText.setText(address.toString());
Good luck!
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow