我需要做一个活动,允许用户点击getLocation按钮,该按钮又根据可能性分数返回地点列表。来自FindCurrentPlaceResponse的响应返回20个项目,我希望它们以列表或卡片视图的形式出现,用户最终从中选择最合适的位置。如何使响应返回可放入可点击列表中的各个位置?
我已经遵循并完全使用谷歌地点文档 https://github.com/googlemaps/android-places-demos 我的活动
这是文档中将列表转换为单个字符串的确切代码
@RequiresPermission(allOf = {ACCESS_FINE_LOCATION, ACCESS_WIFI_STATE})
private void findCurrentPlaceWithPermissions() {
setLoading(true);
FindCurrentPlaceRequest currentPlaceRequest = FindCurrentPlaceRequest.newInstance(getPlaceFields());
Task<FindCurrentPlaceResponse> currentPlaceTask = placesClient.findCurrentPlace(currentPlaceRequest);
currentPlaceTask.addOnSuccessListener(
(response) ->
responseView.setText(StringUtil.stringify(response, isDisplayRawResultsChecked())));
currentPlaceTask.addOnFailureListener(
(exception) -> {
exception.printStackTrace();
responseView.setText(exception.getMessage());
});
currentPlaceTask.addOnCompleteListener(task -> setLoading(false));
}
繁花如伊
德玛西亚99
随时随地看视频慕课网APP
相关分类