android PlaceAutocompleteFragment Search widget 由 Google Places 提供,结果层出不穷

Results are coming one over another in android PlaceAutocompleteFragment Search widget Provided by Google Places

我使用 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 的自动完成小部件中的一个已知问题。它将在即将发布的版本中修复。