Android的对话框而不按钮 [英] Android Dialog Box without buttons

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

问题描述

我可以创建没有正面或负面的按钮的对话框。这之后的具体行动破坏了它的自我?

  AlertDialog.Builder dialog_detect =新AlertDialog.Builder(MainActivity.this);
 dialog.setTitle(检测......);
 dialog.setMessage(请等待);
 dialog.show();


解决方案

您可以做到这一点很容易。

  AlertDialog.Builder alertDialogBu​​ilder =新AlertDialog.Builder(背景);//设置标题
alertDialogBu​​ilder.setTitle(您的标题);//设置对话框消息
alertDialogBu​​ilder.setMessage(消息在这里!)setCancelable(假)。//创建警报对话框
AlertDialog alertDialog = alertDialogBu​​ilder.create();// 展示下
alertDialog.show();//一些动作后
alertDialog.dismiss();

如果你有一个参考 AlertDialog 其他地方,你仍然可以调用 alertDialog.dismiss()。这将关闭对话框。

Can i create a dialog box without negative or positive buttons. That destroys it self after specific action?

 AlertDialog.Builder dialog_detect= new AlertDialog.Builder(MainActivity.this);
 dialog.setTitle("Detecting.....");
 dialog.setMessage("Please Wait");
 dialog.show();

解决方案

You can do this very easily.

AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);

// set title
alertDialogBuilder.setTitle("Your Title");

// set dialog message
alertDialogBuilder.setMessage("Message here!").setCancelable(false);

// create alert dialog
AlertDialog alertDialog = alertDialogBuilder.create();

// show it
alertDialog.show();

// After some action
alertDialog.dismiss();

If you have a reference to the AlertDialog somewhere else, you can still call alertDialog.dismiss(). This closes the dialog.

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

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