Android Google Places API-PlaceAutocompleteFragment清除按钮侦听器

巴拉特什

在我的项目中使用Android的Google Places API-PlaceAutocompleteFragment API来搜索位置,当用户选择一个位置,然后使用经纬度的位置获取记录并将其显示到ListView时。

现在的问题是,每当用户点击PlaceAutocompleteFragment的清除按钮(X)时我都想清除需要收听清除按钮onClick的ListView项目?怎么做?任何帮助将不胜感激。

在此处输入图片说明

autocompleteFragment.setOnPlaceSelectedListener(new PlaceSelectionListener() {
    @Override
    public void onPlaceSelected(Place place) {
        LatLng latLng=place.getLatLng();
        //hit web service, response parsing and add it to listview.
    }

    @Override
    public void onError(Status status) {
        Log.i(TAG, "An error occurred: " + status);
    }
});
巴拉特什

PlaceAutocompleteFragment查看我的源代码,我发现了这些视图ID并设置onClickListener如下:

autocompleteFragment.getView().findViewById(R.id.place_autocomplete_clear_button)
    .setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            // example : way to access view from PlaceAutoCompleteFragment
            // ((EditText) autocompleteFragment.getView()
            // .findViewById(R.id.place_autocomplete_search_input)).setText(""); 
            autocompleteFragment.setText("");
            view.setVisibility(View.GONE);
        }
});

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Android PlaceFilter与Google Places API的配合使用

Android google Places API 超出每日配额

Google Places API Android resultCallback无法启动

Android解析Google Places API JSON

Android Places API:模拟器上的Google Play服务已过期

Google Places APi照片

Google Places API替代

Google Places 活动 API

违反Google Places API

Python,Google Places API

Google Places API的使用

Android Google Places API,getAutocompletePredictions返回状态为“ PLACES_API_ACCESS_NOT_CONFIGURED”

适用于Android应用的Google Places API密钥

Google Places API返回INVALID_REQUEST(Android)

Google Places API Android:自动补全功能关闭太快

使用Android应用程序中用于服务器Web的Google Places API KEY请求拒绝

超出 Google Places API 配额

如何查询Google Places API?

Flutter中的Google Places API

在Android中使用Google Places API时出现错误“状态{statusCode = PLACES_API_INVALID_APP,分辨率=空}”

带有10.2.0的Google Play服务(Google Places API Android)获得例外

结合Google Places API和Facebook Places API

RuntimeExecutionException:com.google.android.gms.common.api.ApiException:13:错误Places API

使用Google Places API获取google +评论

在Google表格中使用Google Places API

Google Places API:了解Places自动完成响应的解析

Google Places for Android API密钥不适用于Play商店中的应用

如何为我的Android应用程序获取Google Places API密钥

尝试访问Google Play服务Android时出现PLACES_API_INVALID_APP错误