问题
I have added the Place Autocomplete to my app but when I touch the search button it comes and then disappearing. I couldn't type in the search it disappearing. Disappearing means there's search bar but if we touch googles search bar will come out and we can type there. But It's coming and then it suddenly disappears.
This is the code in XML.
<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:name="com.google.android.gms.location.places.ui.PlaceAutocompleteFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.v7.widget.Toolbar>
回答1:
it's working and Android API key should be added to the manifest! So it will work !https://developers.google.com/places/android-api/
回答2:
I was having the same problem. What caused my problem was the api I was using was old and wasn't registered for an android project. So I registered a new project here https://console.developers.google.com and replaced the old api with the new one. Then it worked.
So basically, what was happening was that when you try to search, the api gets refused by google's servers, so it prevents you from searching.
来源:https://stackoverflow.com/questions/46487600/place-autocomplete-not-working-properly-android