Android PlaceAutocompleteFragment自动关闭
创始人
2024-08-15 00:30:14
0

要实现Android PlaceAutocompleteFragment自动关闭,你可以使用以下方法:

  1. 在布局文件中添加PlaceAutocompleteFragment:

  1. 在Activity中初始化PlaceAutocompleteFragment并设置监听器:
PlaceAutocompleteFragment autocompleteFragment = (PlaceAutocompleteFragment)
    getFragmentManager().findFragmentById(R.id.place_autocomplete_fragment);
autocompleteFragment.setOnPlaceSelectedListener(new PlaceSelectionListener() {
    @Override
    public void onPlaceSelected(Place place) {
        // 当选择一个地点时执行的操作
    }

    @Override
    public void onError(Status status) {
        // 发生错误时执行的操作
    }
});
  1. 添加一个方法来关闭PlaceAutocompleteFragment:
private void closeAutocompleteFragment() {
    // 查找PlaceAutocompleteFragment的视图
    View fragmentView = findViewById(R.id.place_autocomplete_fragment);
    // 如果视图存在且可见
    if (fragmentView != null && fragmentView.getVisibility() == View.VISIBLE) {
        // 隐藏视图并删除它
        fragmentView.setVisibility(View.GONE);
        getFragmentManager().beginTransaction().remove(autocompleteFragment).commit();
    }
}
  1. 在onPlaceSelected()方法中调用closeAutocompleteFragment()方法来自动关闭PlaceAutocompleteFragment:
@Override
public void onPlaceSelected(Place place) {
    // 当选择一个地点时执行的操作
    closeAutocompleteFragment();
}

这样,当用户选择一个地点后,PlaceAutocompleteFragment将自动关闭。

相关内容

热门资讯

据悉!wepokerplus脚... 据悉!wepokerplus脚本(透视)途游破解版无限钻石(一直真的有辅助平台)-哔哩哔哩1、起透看...
连日来!hhpoker辅助器视... 连日来!hhpoker辅助器视频(透视)越乡游金花辅助(其实真的有辅助软件)-哔哩哔哩1、点击下载安...
据统计!hhpoker德州牛仔... 据统计!hhpoker德州牛仔视频(透视)微信微乐辅助器下载(原来有辅助下载)-哔哩哔哩1、很好的工...
近年来!aapoker俱乐部靠... 近年来!aapoker俱乐部靠谱吗(透视)途游四川小程序规律(一贯有辅助下载)-哔哩哔哩1、全新机制...
连日来!hhpkoer辅助器(... 连日来!hhpkoer辅助器(透视)微信边锋辅助软件(真是是有辅助app)-哔哩哔哩1、上手简单,内...
为了进一步!hhpoker到底... 为了进一步!hhpoker到底可以作必弊码(透视)闲逸透视app安装步骤详解(真是是真的辅助软件)-...
透视辅助!pokerrrr2辅... 透视辅助!pokerrrr2辅助(透视)新道游开挂(真是有辅助软件)-哔哩哔哩1、新道游开挂公共底牌...
出乎意料的是!约局吧app有挂... 出乎意料的是!约局吧app有挂吗(透视)小程序牵手跑辅助器(确实真的有辅助神器)-哔哩哔哩1)小程序...
为切实保障!wepoker买钻... 为切实保障!wepoker买钻石有用吗(透视)科乐填大坑作必弊视频(原来有辅助神器)-哔哩哔哩一、科...
据悉!wepoker破解器有用... 据悉!wepoker破解器有用吗(透视)爱玩联盟辅助软件(一直是有辅助修改器)-哔哩哔哩1、据悉!w...