Android Dialog Box without buttons

前端 未结 9 2548
余生分开走
余生分开走 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:19

    You can also write crocboy's code like this:

    AlertDialog alertDialog = new AlertDialog.Builder(context)    
        .setTitle("Your Title")
        .setMessage("Message here!")
        .setCancelable(false)
        .create();
    
    alertDialog.show();
    
    // After some action
    alertDialog.dismiss(); 
    

    It does exactly the same thing, it's just more compact.

提交回复
热议问题