android - 放置自动完成 fragment 清除按钮设置可见性消失

标签 android google-places-api google-widget

我获取并获取当前位置和选定位置但是当我按下取消十字按钮时它将全部清除,但现在无法从变量中清除..请帮助我 提前致谢

最佳答案

这个解决方案对我有用:

<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/

相关文章:

java - 从 AlertDialog 获取并比较密码

android - Firebase 身份验证 - 发生网络错误(例如超时、连接中断或主机无法访问)

android - 你能在使用 LibGDX 时获得 Android MotionEvents

android - 编写一个在android中关闭主应用程序时执行的后台程序

java - 无法在 setTypeFilter() 中使用两个 typeFilters 进行 Google 地方信息 2019 更新

javascript - 限制 Google Places Api 结果

javascript - (PHP/JS)Google Maps API 3在IE,FF和iPad(Safari/Chrome)中未获得结果,但在Chrome&M8 Android( native /Chrome)中获得结果

javascript - 如何在点击元素时触发网页的谷歌翻译?