草庐IT

getButtons

全部标签

android - 为什么 alert.getButton(AlertDialog.BUTTON_POSITIVE) 返回 NULL?

(不好意思,发现这个问题已经有人回答了,见下文)所以,我先triedtoextendtheAlertDialog这样我就可以用弹出窗口中需要的EditText做一些事情,但是当Icouldntgetthattowork,我现在在我的MainActivity中使用普通的AlertDialog.Builder来创建我需要的东西。下面的代码创建了一个AlertDialog并使用“setView”将我的自定义View添加到其中。当AlertDialog第一次显示时,它的POSITIVT按钮应该被禁用,只有当所有的EditTexts都有文本时,POSITIVT按钮才应该被启用。所以我尝试通过在使

android - alertDialog.getButton() 方法给出空指针异常android

我打算用layout_weight=1创建3个按钮,对自定义对话框不感兴趣。所以我写了下面的代码。它不起作用。总是是按钮给我null。这段代码有什么问题?AlertDialogdialog=newAlertDialog.Builder(this).create();dialog.setIcon(R.drawable.alert_icon);dialog.setTitle("title");dialog.setMessage("Message");dialog.setButton(AlertDialog.BUTTON_POSITIVE,"Yes",newDialogInterface.O