Android Dialog Box without buttons

2020-08-10 19:45发布

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();

标签: android
9条回答
对你真心纯属浪费
2楼-- · 2020-08-10 20:10

Correct code of crocboy's answer is this:

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

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

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

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

// show it
alertDialog.show();

// After some action
alertDialog.dismiss(); 
查看更多
地球回转人心会变
3楼-- · 2020-08-10 20:12

to show dialog:-

ProgressDialog pd = ProgressDialog.show(context,"TITLE","MSG");

to dismiss

pd.dismiss();
查看更多
时光不老,我们不散
4楼-- · 2020-08-10 20:12

You can try custom dialog as you like

Dialog dialog_help = new Dialog(this);
dialog_help.setContentView(R.layout.title_multi_selectitems_dialog);
EditText et_1 = (EditText) dialog_help.findViewById(R.id.et_help_1);
dialog_help.setCancelable(true);
dialog_help.setTitle("   Help   ");
dialog_help.setCanceledOnTouchOutside(true);
dialog_help.show();
dialog_help.getWindow().setGravity(Gravity.CENTER);
dialog_help.getWindow().setLayout(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT);
查看更多
登录 后发表回答