android – AlertDialog没有显示两个按钮

android – AlertDialog没有显示两个按钮,第1张

概述AlertDialog没有显示发送按钮.下面是代码.请告诉我我的代码中犯了什么错误. protected Dialog onCreateDialog(int id) { final AlertDialog.Builder dialog = new AlertDialog.Builder(this); dialog.setMessage("Enter Holla message"); AlertDialog没有显示发送按钮.下面是代码.请告诉我我的代码中犯了什么错误.

protected Dialog onCreateDialog(int ID) {    final AlertDialog.Builder dialog = new AlertDialog.Builder(this);    dialog.setMessage("Enter Holla message");    EditText hollaMessage = new EditText(this);    dialog.setVIEw(hollaMessage);    dialog.setCancelable(false);    dialog.setPositivebutton("Send",new DialogInterface.OnClickListener() {       public voID onClick(DialogInterface dialog,int ID) {          List result = new ArrayList();       }    });    dialog.setPositivebutton("Cancel",new DialogInterface.OnClickListener() {        public voID onClick(DialogInterface dialog,int which) {            dismissDialog(0);        }    });    AlertDialog alert = dialog.create();    return alert;}
解决方法 你设置了两次正面按钮..使它setNagativebutton(“取消”…..

protected Dialog onCreateDialog(int ID){    final AlertDialog.Builder dialog = new AlertDialog.Builder(this);    dialog.setMessage("Enter Holla message");    EditText hollaMessage = new EditText(this);    dialog.setVIEw(hollaMessage);    dialog.setCancelable(false);    dialog.setPositivebutton("Send",int ID) {            List result = new ArrayList();        }    });    dialog.setNegativebutton("Cancel",int which) {            dismissDialog(0);        }    });    AlertDialog alert = dialog.create();    return alert;}
总结

以上是内存溢出为你收集整理的android – AlertDialog没有显示两个按钮全部内容,希望文章能够帮你解决android – AlertDialog没有显示两个按钮所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1121761.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-29
下一篇2022-05-29

发表评论

登录后才能评论

评论列表(0条)

    保存