gpt4 book ai didi

android - 如何在关闭 AlertDialog 时调用函数?

转载 作者:行者123 更新时间:2023-11-29 21:05:30 25 4
gpt4 key购买 nike

我用 ListView 创建了一个 AlertDialog。创建 AlertDialog 时,它还会开始扫描 BLE 设备。当用户单击其中一项时,将调用 scanLeDevice 函数,这将停止进一步扫描。我想知道当我在 AlertDialog 之外单击时如何调用此函数?

public class BLEScan extends AlertDialog {
....
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

...
bleList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
BLEScan.this.scanLeDevice(false);
selectedBluetoothDevice =(BluetoothDevice) (bleList.getItemAtPosition(i));
BLEScan.this.dismiss();
}
});

最佳答案

通过setOnDismissListener()设置一个OnDismissListener

关于android - 如何在关闭 AlertDialog 时调用函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24711281/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com