Android 获取textview中的当前位置

Android 获取textview中的当前位置,android,google-maps,Android,Google Maps,每当我在谷歌地图中点击一个特定位置时,我都希望该位置的名称显示在文本视图中。有什么方法可以做到吗?获取特定位置的lat_lng值,然后将lat lng值传递给geocoder方法 public void getgetLocationAddress(Context context,double lat,double lng){ Geocoder geocoder; List<Address> addresses; geocoder = new Geo

每当我在谷歌地图中点击一个特定位置时,我都希望该位置的名称显示在文本视图中。有什么方法可以做到吗?

获取特定位置的lat_lng值,然后将lat lng值传递给geocoder方法

    public  void getgetLocationAddress(Context context,double lat,double lng){
    Geocoder geocoder;
    List<Address> addresses;

    geocoder = new Geocoder(context, Locale.getDefault());
    try {
        addresses = geocoder.getFromLocation(lat, lng, 1); // Here 1 represent max location result to returned, by documents it recommended 1 to 5
          address = addresses.get(0).getAddressLine(0); // If any additional address line present than only, check with max available address lines by getMaxAddressLineIndex()
        city = addresses.get(0).getLocality();
        String state = addresses.get(0).getAdminArea();
        country = addresses.get(0).getCountryName();
       // System.out.println("SDK_DATA"+address+"..."+city +country);

          //Here address set to your textview
    } catch (IOException e) {
        e.printStackTrace();
    } }

把你的代码贴在这里搜索Google@IntelliJAmiya我已经在谷歌上搜索过了。我找到的是从文本视图中搜索的位置。但不用于在文本视图中显示所选位置。如果您有任何线程,请在此处提供。地址、城市和国家是字符串变量