gpt4 book ai didi

android - 如何在 android google place 的自动完成 Activity 中更改占位符文本?

转载 作者:行者123 更新时间:2023-12-04 22:28:22 25 4
gpt4 key购买 nike

我正在使用 Option 2: Use an intent to launch the autocomplete activity

是否可以将“搜索”占位符文本更改为“输入您的城市”之类的内容。我找到了a solution但对于 javascript,假设也支持 android。

似乎可以使用 a PlaceAutocompleteFragment 来完成,但我使用我自己的 EditText 通过使用 Intent 来启动自动完成,所以它没有帮助。

enter image description here

最佳答案

不,没有办法,如果你想要,你必须创建自己的。
但是当您使用 EditText(在评论部分提及)时,这种技术可能对您有用。

代码:

PlaceAutocompleteFragment autocompleteFragment;
autocompleteFragment = (PlaceAutocompleteFragment)
getFragmentManager().findFragmentById(R.id.place_autocomplete_fragment);
autocompleteFragment.setOnPlaceSelectedListener(this);
autocompleteFragment.setHint("Search New Location");

xml:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/left_drawable_padding"
android:layout_marginTop="@dimen/margin_five"
android:layout_marginLeft="@dimen/margin_five"
android:layout_marginRight="@dimen/margin_five"
android:background="@drawable/search_background"
android:orientation="vertical">
<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:background="@drawable/search_background"所以你必须创建自己的背景形状(根据你的需要)。

第一张图片:
enter image description here

第二张图:
enter image description here

第三张图:
enter image description here

第四张图:
enter image description here

关于android - 如何在 android google place 的自动完成 Activity 中更改占位符文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45366037/

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