Android Dialog Box without buttons

前端 未结 9 2496
余生分开走
余生分开走 2021-02-19 06:52

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

 AlertDialog.Builder dialog_detect= new AlertDialog.         


        
9条回答
  •  醉话见心
    2021-02-19 07:24

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

提交回复
热议问题