【发布时间】:2019-10-01 16:08:04
【问题描述】:
我正在尝试在 editText 的 onClick 事件中扩充使用 Google Places API 的 AutoCompleteSupportFragment。
我想在点击editText时为该片段充气,以便用户可以输入一个位置,从自动完成片段中的建议中选择,位置名称将显示在editText上。
我检查了这个链接here,但它对我不起作用。
places_auto_complete_fragment.xml
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/place_autocomplete_fragment"
android:name="com.google.android.libraries.places.widget.AutocompleteSupportFragment" />
我是如何充气的
sourceEditText.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
LayoutInflater layoutInflater = getLayoutInflater();
layoutInflater.inflate(R.layout.places_auto_complete_fragment,addTripLinearLayout,false);
}
});
感谢任何帮助。谢谢
【问题讨论】:
-
工藤的@arnavJJ
标签: android android-fragments android-edittext google-places-api onclicklistener