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

相关内容

热门资讯

六分钟了解!德普辅助app(辅... 六分钟了解!德普辅助app(辅助挂)总是有挂(有挂方略)1)德普辅助app辅助插件:进一步探索德普辅...
分享一款!wpk真的有透视嘛(... 分享一款!wpk真的有透视嘛(辅助挂)确实真的是有挂(有挂秘籍)wpk真的有透视嘛辅助器是一种具有地...
每日必看推荐!wepoker透... 每日必看推荐!wepoker透视脚本苹果版(辅助挂)竟然真的有挂(有挂分析)1、实时wepoker透...
分享给玩家!wepoker到底... 分享给玩家!wepoker到底有没有透视(辅助挂)原来有挂(有挂解密)1、wepoker到底有没有透...
实测教程!hhpoker开挂教... 实测教程!hhpoker开挂教程(辅助挂)果然真的有挂(有挂详细)1、首先打开hhpoker开挂教程...
科技通报!拱趴大菠萝挂怎么安装... 科技通报!拱趴大菠萝挂怎么安装(辅助挂)都是真的是有挂(今日头条)1)拱趴大菠萝挂怎么安装有没有挂:...
必看攻略!模拟器打开hhpok... 必看攻略!模拟器打开hhpoker(辅助挂)真是有挂(有挂实锤)必看攻略!模拟器打开hhpoker(...
教程攻略!大菠萝免费辅助器(辅... 教程攻略!大菠萝免费辅助器(辅助挂)竟然真的有挂(有挂分享)一、大菠萝免费辅助器游戏安装教程牌型概率...
必备教程!hh poker透视... 必备教程!hh poker透视器下载(辅助挂)真是是真的有挂(有挂教程)1、每一步都需要思考,不同水...
揭秘攻略!wepoker辅助器... 揭秘攻略!wepoker辅助器软件下载(辅助挂)果然是真的有挂(真的有挂)1、首先打开wepoker...