Android : How to get the first value of Arraylist

on Wednesday, September 17, 2014


I am working on map v2. I wanted to convert latitude and longitude into the text address.So i used Geocoder class to locate the address. Now the problem is when i used List, it gives so many confusing locations. It might be the list of locations. I want to retrieve just the first location among them and pass that location to another activity. How can i do that? Please help.Its an emergency.Below is my code:



try {
Geocoder gcd = new Geocoder(this, Locale.getDefault());
List<Address> addresses = gcd.getFromLocation( dmylats, dmylong, 1);

if (addresses.size() > 0)
Toast.makeText(this, "You are at "+addresses,Toast.LENGTH_LONG).show();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}


I just want the first value among the List.


0 comments:

Post a Comment