java - Google Place Autocomplete 破坏了它所在的父片段
问题描述
我有一个谷歌地方自动完成片段实现如下
AutocompleteSupportFragment autocompleteFragment = (AutocompleteSupportFragment)
getChildFragmentManager().findFragmentById(R.id.autocomplete_fragment);
autocompleteFragment.setPlaceFields(Arrays.asList(Place.Field.ID, Place.Field.NAME, Place.Field.LAT_LNG));
LatLng center = ((LocationActivity)getActivity()).getLastLocationLatLng();
if (center != null){
LatLng northSide = SphericalUtil.computeOffset(center, 50000, 0);//50,000 meters
LatLng southSide = SphericalUtil.computeOffset(center, 50000, 180);
LatLngBounds bounds = LatLngBounds.builder()
.include(northSide)
.include(southSide)
.build();
autocompleteFragment.setLocationBias(RectangularBounds.newInstance(bounds));
}
autocompleteFragment.setOnPlaceSelectedListener(new PlaceSelectionListener() {
@Override
public void onPlaceSelected(Place place) {
Log.i(GlobalVar.TAG, "Place: " + place.getName() + ", " + place.getId());
selectedLatLng = place.getLatLng();
}
@Override
public void onError(Status status) {
Log.i(GlobalVar.TAG, "An error occurred: " + status);
}
});
此小部件位于 BottomNavigationView 的其中一个片段中。
所以底部导航视图->第三个选项卡->你会看到谷歌地方搜索
当我单击搜索、输入并选择其中一个结果时,应用程序会返回到第一个选项卡!
我确实被Log.i(GlobalVar.TAG, "Place: " + place.getName() + ", " + place.getId());
执行了,这意味着自动完成检索了结果,但由于某种原因,父片段(第三个选项卡)被破坏/分离
你有什么建议?
谢谢
解决方案
推荐阅读
- docker-compose - 如何在 docker 上为 Trafik 添加新的子域/多个域以及配置重构时重新发布让我们加密
- swift - 未捕获的异常“NSInvalidArgumentException”,原因:“-[UITableViewSection 视图]:无法识别的选择器发送到实例 0x600003721110”
- java - Java Nested ArrayList not Adding Correctly
- javascript - Parse JSON string to javascript object with exact values
- mongodb - Create Index by population ranges
- javascript - 创建一个创建元素的 Javascript 按钮类
- html - 如何在 Chrome 中调整纯 flexbox 砌体网格,这已经在 Firefox 中有效
- gcc - 例程地址错误,在 ubuntu 18.04 上重新编译古代 linux-0.12 时
- ajax - 如何在循环例程中解决“未捕获的 ReferenceError:$ 未定义”
- vb.net - 操作物理功能按钮(windows)