Timmy-zzh / TDialog

DialogFragment封装,高效实现各种弹窗效果

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

弹框弹出来后,如何监听到返回键?

lfzzj opened this issue · comments

commented
commented

TDialog目前没复写这个方法,后期可以加上.
当前你可以这样实现:
TDialog tDialog = //... ;
tDialog.getDialog().setOnKeyListener(new DialogInterface.OnKeyListener() {
@OverRide
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
return false;
}
});

TDialog目前没复写这个方法,后期可以加上.
当前你可以这样实现:
TDialog tDialog = //... ;
tDialog.getDialog().setOnKeyListener(new DialogInterface.OnKeyListener() {
@OverRide
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
return false;
}
});

@Timmy-zzh
我在.show()之后调用tDialog.getDialog() 确为null。好像DialogFragment返回的dialog并没有在TDialog 创建后(.create())被立即执行。而是在onGetLayoutInflater里面被赋值的。请问有其他解决方案吗

commented

同样遇到这个问题,我看看1.31版本能否解决

commented

.setCancelable(false),在1.3.1版本有这个,求新版本添加

我也想监听返回键,也是同样问题,.show()之后调用tDialog.getDialog() 确为null

commented

作者,我恢复到1.3版本,然后发现有时候会出现设置了.setCancelable(false) 以后,确认和取消按钮无法点击的情况,于是时间紧迫自己写了个dialog临时用- -求修复

commented

已更新,最新版2.1.0添加了返回键点击监听