java.lang.RuntimeException: Unable to start activity ComponentInfo{<package>}: java.lang.IllegalArgumentException: button does not exist
该错误指向尚未调用的方法.
private voID dialog(String Title,String content){ AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create(); alertDialog.setTitle(Title); alertDialog.setMessage(content); alertDialog.setCancelable(true); alertDialog.setbutton(1,"OK",new DialogInterface.OnClickListener() { public voID onClick(DialogInterface dialog,int which) { dialog.dismiss(); } }); alertDialog.show();}
我试图在其他项目中复制并使用该代码 – 结果相同,并且它不久前工作(相同的目标API等).知道我在忽视什么吗?
解决方法 不要在setButton(...)
中硬编码1.使用 DialogInterface
类中的常量指定哪个按钮: DialogInterface.BUTTON_NEGATIVE
DialogInterface.BUTTON_POSITIVE
DialogInterface.BUTTON_NEUTRAL
以上是内存溢出为你收集整理的android – AlertDialog按钮不存在全部内容,希望文章能够帮你解决android – AlertDialog按钮不存在所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)