为什么AlertDialog.Builder没有setOnDismissListener或setOnShowListener方法呢? [英] Why does AlertDialog.Builder not have setOnDismissListener or setOnShowListener methods?

查看:1964
本文介绍了为什么AlertDialog.Builder没有setOnDismissListener或setOnShowListener方法呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用AlertDialog.Builder的流体界面,但是当我去加入我的DismissListener和ShowListener点我一定要打破,并将其添加到()在Builder对话框对象我做我的创建后。有谁知道为什么他们不是在那里?我不能延长,因为私有P成员的...这是不是世界或任何月底,我只是好奇,为什么它不存在。

I want to use the fluid interface of AlertDialog.Builder but when I get to the point of adding my DismissListener and ShowListener I have to break out and add it to the dialog object after I do my create() on the builder. Does anyone know why they're not on there? I can't extend it because of the private P member... It's not the end of the world or anything, I'm just curious why it's not there.

推荐答案

你尝试过这种方法。

AlertDialog dlg = builder.create();
lg.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(final DialogInterface dialog) {
//Do some work
}
});
return dlg;

这篇关于为什么AlertDialog.Builder没有setOnDismissListener或setOnShowListener方法呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆