Android AlertDialog 单按钮 [英] Android AlertDialog Single Button

查看:36
本文介绍了Android AlertDialog 单按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要一个 AlertDialog 构建器,它只有一个按钮,上面写着 OK 或 Done 之类的,而不是默认的 yes 和 no.这可以用标准的 AlertDialog 来完成,还是我必须使用其他东西?

I'd like to have an AlertDialog builder that only has one button that says OK or Done or something, instead of the default yes and no. Can that be done with the standard AlertDialog, or would I have to use something else?

推荐答案

难道不能只用一个肯定的按钮来完成吗?

Couldn't that just be done by only using a positive button?

AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Look at this dialog!")
       .setCancelable(false)
       .setPositiveButton("OK", new DialogInterface.OnClickListener() {
           public void onClick(DialogInterface dialog, int id) {
                //do things
           }
       });
AlertDialog alert = builder.create();
alert.show();

这篇关于Android AlertDialog 单按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆