Android 放置自动完成无法正常工作
我已经将搜索添加到我的应用程序中,但当我按下搜索按钮时,它会出现,然后消失。我无法输入搜索结果,它正在消失。消失意味着有搜索栏,但若我们触摸谷歌搜索栏就会出来,我们可以在那个里打字。但它来了,然后突然消失了 这是XML中的代码Android 放置自动完成无法正常工作,android,android-layout,android-fragments,google-places,Android,Android Layout,Android Fragments,Google Places,我已经将搜索添加到我的应用程序中,但当我按下搜索按钮时,它会出现,然后消失。我无法输入搜索结果,它正在消失。消失意味着有搜索栏,但若我们触摸谷歌搜索栏就会出来,我们可以在那个里打字。但它来了,然后突然消失了 这是XML中的代码 <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?
<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>
它正在工作,应该将Android API密钥添加到清单中!所以它会起作用的! 我也有同样的问题。导致我出现问题的原因是我使用的api很旧,没有注册android项目。
所以我在这里注册了一个新项目
并用新的api替换了旧的api。然后它成功了
因此,基本上,当你尝试搜索时,api被谷歌服务器拒绝,因此它阻止你搜索。而不是你为什么不使用
autocompletedadapter
并将其与PlaceAPI绑定?@stutikasliwal文档没有规定它。好的,为了理解代码及其问题,您还必须共享活动代码。使用Autocomplete和PlaceAPI将更方便、更容易实现,您可以尝试一下once@stutikasliwal我很清楚这一点,但问题不在于我点击搜索按钮时会消失。这意味着另一个弹出式搜索按钮将出现,它将询问在一秒钟内自动消失。这张图片将给出一些关于自动完成的想法。我仍然有这个问题,并且我在清单文件中有API密钥。你解决问题了吗?怎么用?