gpt4 book ai didi

android - 结果在 Android PlaceAutocompleteFragment 搜索小部件中一个接一个地出现,由 Google Places 提供

转载 作者:行者123 更新时间:2023-11-29 19:41:38 25 4
gpt4 key购买 nike

我使用 Google Places Api 提供的 PlaceAutocompleteFragment 将自动完成搜索集成到我的 Android 应用程序中。它工作正常,但问题是有时自动完成列表中的结果会一个接一个地出现。我无法思考这个问题。我正在添加相同的屏幕截图和代码。

Screenshot of the problem

代码-

布局代码-

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/coord"
android:fitsSystemWindows="true"
tools:context="com.restaurantfinder.lazylad91.restaurantfinder.HomeActivity">

<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay">
<fragment
android:id="@+id/place_autocomplete_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:name="com.google.android.gms.location.places.ui.PlaceAutocompleteFragment"
/>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>

<include layout="@layout/content_home"/>

<!-- <android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
android:src="@android:drawable/ic_dialog_email"/>-->

</android.support.design.widget.CoordinatorLayout>

Activity 代码-

    AutocompleteFilter typeFilter = new AutocompleteFilter.Builder()
.setTypeFilter(AutocompleteFilter.TYPE_FILTER_ESTABLISHMENT)
.build();
autocompleteFragment.setFilter(typeFilter);

autocompleteFragment.setOnPlaceSelectedListener(new PlaceSelectionListener() {
@Override
public void onPlaceSelected(Place place) {
// TODO: Get info about the selected place.
mPlaceSelected = place;

}
Log.d("TAG", "Place: " + place.getName());//get place details here
}

更新

此错误已由 Google 处理

https://issuetracker.google.com/issues/35829225

此修复已在 Google Play Services 9.6(2016 年 9 月 21 日)中实现

最佳答案

这是 Android 自动完成小部件中的一个已知问题。它将在即将发布的版本中修复。

关于android - 结果在 Android PlaceAutocompleteFragment 搜索小部件中一个接一个地出现,由 Google Places 提供,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38564267/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com