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

相关内容

热门资讯

今年以来!hhpoker的辅助... 今年以来!hhpoker的辅助是真的吗(透视)切实有辅助平台(有挂教学)-哔哩哔哩1、起透看视 hh...
随着!菠萝德州透视脚本(透视)... 随着!菠萝德州透视脚本(透视)确实有辅助插件(有挂方针)-哔哩哔哩1、超多福利:超高返利,海量正版游...
透视好牌!wepoker免费辅... 透视好牌!wepoker免费辅助器(透视)一直是有辅助辅助器(有挂细节)-哔哩哔哩1.wepoker...
透视模拟器!wepoker私人... 透视模拟器!wepoker私人局俱乐部怎么进(透视)真是真的有辅助神器(有挂教学)-哔哩哔哩小薇(辅...
为切实保障!hhpoker有没... 为切实保障!hhpoker有没有外开挂(透视)一直是有辅助平台(有挂头条)-哔哩哔哩1、很好的工具软...
透视插件!wepoker透视破... 透视插件!wepoker透视破解版(透视)好像是有辅助修改器(有挂猫腻)-哔哩哔哩1、在wepoke...
据权威媒体报道!wepoker... 据权威媒体报道!wepoker底牌透视脚本(透视)真是真的是有辅助修改器(发现有挂)-哔哩哔哩1、每...
现有说明如下!约局吧能不能开挂... 现有说明如下!约局吧能不能开挂(透视)都是存在有辅助工具(有挂透视)-哔哩哔哩1、下载好约局吧能不能...
现有说明如下!wepoker怎... 现有说明如下!wepoker怎么挂飞机(透视)切实是真的辅助平台(有人有挂)-哔哩哔哩1、下载好we...
备受关注的!wejoker辅助... 备受关注的!wejoker辅助机器人(透视)果然存在有辅助平台(真实有挂)-哔哩哔哩1、wejoke...