How do I display an alert dialog on Android?

后端 未结 30 2364
清歌不尽
清歌不尽 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:37

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle("This is Title");
        builder.setMessage("This is message for Alert Dialog");
        builder.setPositiveButton("Positive Button", (dialog, which) -> onBackPressed());
        builder.setNegativeButton("Negative Button", (dialog, which) -> dialog.cancel());
        builder.show();
    

    This is a way which alike to create the Alert dialog with some line of code.

提交回复
热议问题