我很困惑为什么我的对话框无法正常工作:
AlertDialog dialog;
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
final CharSequence[] confirmCheckbox = {"Delete the SQLite database upon exit."};
final boolean states[] = {false};
builder.setTitle("Delete Database on Exit?");
builder.setMultiChoiceItems(confirmCheckbox, states, new DialogInterface.OnMultiChoiceClickListener(){
public void onClick(DialogInterface dialogInterface, int item, boolean state) {
}
}).setMessage("Check the checkbox below to confirm that you wish to delete the SQLite database upon exit.\n" +
"To cancel this action, hit the back button.")
.setPositiveButton(R.string.confirm_button_text, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
dialog = builder.create();
//dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false); <-- This will fail. BUTTON_POSITIVE is NULL
dialog.show();
我遇到的第一个问题是没有任何显示。我得到标题,它的每一侧都有两个奇怪的白条,中间有一个黑屏,还有一个正按钮,但我无法引用正按钮,因为当我这样做时我得到一个空指针。
我读过很多教程 http://www.learn-android-easily.com/2013/01/adding-check-boxes-in-dialog.html,它们看起来都与我所拥有的相似,但我没有运气。有任何想法吗?
None
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)