我获取并获取当前位置和选定位置但是当我按下取消十字按钮时它将全部清除,但现在无法从变量中清除..请帮助我 提前致谢
最佳答案
这个解决方案对我有用:
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<fragment android:name="com.google.android.gms.location.places.ui.PlaceAutocompleteFragment"
android:id="@+id/place_autocomplete_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<View
android:id="@+id/view_callback"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_gravity="right|center_vertical"
android:background="@android:color/transparent"/>
</FrameLayout>
我在 PlaceAutocompleteFragment 上放了一个透明 View 。此 View 应覆盖取消按钮。然后,在 Activity/Fragment 中,获取 View 引用后:
closeCallback.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
autocompleteFragment.setText("");
return true;
}
});
此解决方案有效,因为当您输入空字符串时,我们会获得相同的结果。
关于android - 放置自动完成 fragment 清除按钮设置可见性消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35650825/