There was a problem. There is a toolbar and a button on it. Clicking on the button opens a full-screen Dialog with a margin on the upper toolbar. That is, the toolbar is visible. It has a close button. Question. How to process click on this button and close the Dialog?

  • one
    When a dialogue is called, the activity is paused and it is impossible to interact with it "manually". Why don't you handle the closure in the dialog itself? - Jarvis_J

1 answer 1

You will not be able to interact with the activation while the dialogue is open. However, you can add a button to close the dialog in it.

public class MainActivity extends Activity { AlertDialog.Builder ad; Context context; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); context = MainActivity.this; ad = new AlertDialog.Builder(context); ad.setTitle("Удаление сообщения" ); // заголовок ad.setMessage("Вы действительно хотите его удалить? "); // сообщение ad.setPositiveButton("Да" , new OnClickListener() { public void onClick(DialogInterface dialog, int arg1) { //обрабатывает нажатие кнопки 'Да' } }); ad.setNegativeButton("Нет", new OnClickListener() { public void onClick(DialogInterface dialog, int arg1) { //обрабатывает нажатие кнопки 'Нет' } }); 

It will look something like this:

enter image description here

You can read more here.