How do I display an alert dialog on Android?

后端 未结 30 2518
清歌不尽
清歌不尽 2020-11-22 03:02

I want to display a dialog/popup window with a message to the user that shows \"Are you sure you want to delete this entry?\" with one button that says \'Delete\'. When

30条回答
  •  逝去的感伤
    2020-11-22 03:22

    // Dialog box
    
    public void dialogBox() {
        AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
        alertDialogBuilder.setMessage("Click on Image for tag");
        alertDialogBuilder.setPositiveButton("Ok",
            new DialogInterface.OnClickListener() {
    
                @Override
                public void onClick(DialogInterface arg0, int arg1) {
            }
        });
    
        alertDialogBuilder.setNegativeButton("cancel",
            new DialogInterface.OnClickListener() {
    
            @Override
            public void onClick(DialogInterface arg0, int arg1) {
    
            }
        });
    
        AlertDialog alertDialog = alertDialogBuilder.create();
        alertDialog.show();
    }
    

提交回复
热议问题