java - 设置 Autocompleteplace setupAutocompleteTextView
问题描述
我在 setupAutocompleteTextView 上遇到了 Google Maps Place API 的问题
mAdapter = new PlaceAutocompleteAdapter(this, googleApiClient, BOUNDS, null);
pickUpText.setAdapter(mAdapter);
pickUpText.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
InputMethodManager inputManager =
(InputMethodManager) GoCabActivity.this.getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.hideSoftInputFromWindow(pickUpText.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
AutocompletePrediction item = mAdapter.getItem(position);
getLocationFromPlaceId(item.getPlaceId(), new ResultCallback<PlaceBuffer>() {
@Override
public void onResult(@NonNull PlaceBuffer places) {
final Place place = places.get(0);
LatLng latLng = place.getLatLng();
if (latLng != null) {
gMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
onPickUpClick();
}
}
});
}
});
destinationText.setAdapter(mAdapter);
destinationText.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
InputMethodManager inputManager =
(InputMethodManager) GoCabActivity.this.getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.hideSoftInputFromWindow(destinationText.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
AutocompletePrediction item = mAdapter.getItem(position);
getLocationFromPlaceId(item.getPlaceId(), new ResultCallback<PlaceBuffer>() {
@Override
public void onResult(@NonNull PlaceBuffer places) {
final Place place = places.get(0);
LatLng latLng = place.getLatLng();
if (latLng != null) {
gMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
onDestinationClick();
}
}
});
}
});
logcat 上没有错误,但该功能仍然无法正常工作
解决方案
推荐阅读
- http - 为什么 HttpRequest 在 Dart 中返回 ProgressEvent 错误
- arrays - 从数组中获取指定对象并将其作为变量
- gitlab - 我可以对多个 gitlab 实例使用相同的 gitlab-runner 吗?
- sql - 如何在 SQL Server 中使用 CASE WHEN 函数
- css - 仅使用 css 如何选择第二级 li
- selenium - 使用自定义属性进行 Xunit 测试时,Selenium 浏览器启动两次
- swift - Swift 5 Conversion UnsafeBufferPointer 的这些内存功能是否相同
- r - 使用融化功能
- python - 在 Pandas 中为一组列设置新值
- mysql - Loopback 3 - 删除或编辑涉及映射表的嵌套模型