【发布时间】:2018-03-27 21:20:09
【问题描述】:
这样的小例子,在 Java 中我有:
public static void getPlaceName(GoogleApiClient mGoogleApiClient, String placeId, @NonNull PlaceNameCallback callback) {
Places.GeoDataApi.getPlaceById(mGoogleApiClient, placeId)
.setResultCallback(places -> {
if (places.getStatus().isSuccess() && places.getCount() > 0) {
Place myPlace = places.get(0);
callback.onPlaceDetected(String.valueOf(myPlace.getName())); // set place name
}
places.release();
});
}
public interface PlaceNameCallback {
void onPlaceDetected(String name);
}
然后我可以将地名设置为 TextView:
getPlaceName(mGoogleApiClient, arrivalId[0], name -> textArrival.setText(name));
请告诉我如何在 Kotlin 上设置这样的地名?
【问题讨论】:
标签: kotlin kotlin-android-extensions kotlin-extension