我在用选项 2:使用意图启动自动完成活动 https://developers.google.com/places/android-api/autocomplete#option_2_use_an_intent_to_launch_the_autocomplete_activity
是否可以将“搜索”占位符文本更改为“输入您的城市”之类的内容。我发现一个办法 https://developers.google.com/maps/documentation/javascript/places-autocomplete#placeholder_text但对于 javascript,假设也支持 android。
看来可以用一个 PlaceAutocompleteFragment https://stackoverflow.com/questions/36398061/how-to-change-text-size-in-places-autocompletefragment-in-android,但我正在使用自己的 EditText 通过意图来启动自动完成,因此它没有帮助。
不,没有办法,如果你愿意,你必须创建自己的。
但是当您使用 EditText(在评论部分中提及)时,这项技术可能对您有用。
Code:
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"
所以你必须创建你自己的背景形状(根据你的需要)。
first picture :
Second picture :
thrid picture :
Fourth picture :
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)