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将自动关闭。

相关内容

热门资讯

透视私人局!德州局透视脚本免费... 您好,德州局透视脚本免费版下载手机版这款游戏可以开挂的,确实是有挂的,需要了解加去威信【136704...
透视透视挂!wepoker辅助... 透视透视挂!wepoker辅助器是真的吗,哈糖大菠萝免费辅助器,资料教程(竟然是有挂)-哔哩哔哩1、...
透视新版!wepoker怎么买... 透视新版!wepoker怎么买辅助,wepoker分析,机巧教程(真是真的有挂)-哔哩哔哩1、进入游...
透视计算!拱趴大菠萝挂,aap... 透视计算!拱趴大菠萝挂,aapoker怎么设置提高好牌几率,步骤教程(本来存在有挂)-哔哩哔哩1、任...
透视挂!wejoker内置辅助... 透视挂!wejoker内置辅助(透视)开挂辅助技巧(本来真的是有挂)-哔哩哔哩1、wejoker内置...
透视插件!哈糖大菠萝挂法,we... 透视插件!哈糖大菠萝挂法,wepoker透视脚本免费app,演示教程(都是是有挂)-哔哩哔哩1)we...
透视存在!hhpoker真能买... 透视存在!hhpoker真能买到挂吗,扑克之星辅助,模板教程(都是真的有挂)-哔哩哔哩hhpoker...
透视自建房!hhpoker可以... 透视自建房!hhpoker可以控制吗(透视)开挂辅助app(其实是真的挂)-哔哩哔哩该软件可以轻松地...
透视胜率!wepoker透视脚... 透视胜率!wepoker透视脚本免费下载pc(透视)开挂辅助方法(确实是有挂)-哔哩哔哩一、wepo...
透视规律!哈糖大菠萝免费辅助器... 透视规律!哈糖大菠萝免费辅助器,wepoker模拟器哪个好用,大纲教程(切实是有挂)-哔哩哔哩1、下...