Results are coming one over another in android Pla

2019-07-29 18:01发布

问题:

I have used PlaceAutocompleteFragment provided by Google Places Api to integrate Autocomplete search in my Android Application. It is working fine but the problem is sometime the results in autocomplete list is coming one over another. I am not able to think about the issue. I am adding the screenshot and code for the same.

Screenshot of the problem

code -

Layout code -

<?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 code -

    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
        }

UPDATE

This bug was handled by Google in issue

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

The fix was implemented in Google Play Services 9.6 (21 Sep 2016)

回答1:

This is a known issue in the Autocomplete widget for Android. It will be fixed in an upcoming release.