Untitled

 avatar
unknown
plain_text
a year ago
937 B
5
Indexable
public class MyActivity extends AppCompatActivity {
    private boolean isDialogShowing = false;

    // Method to show your dialog
    private void showDialog() {
        if (!isDialogShowing) {
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.setTitle("My Dialog")
                   .setMessage("This is a dialog message.")
                   .setPositiveButton("OK", (dialog, which) -> {
                       // Handle positive button click
                   })
                   .setNegativeButton("Cancel", (dialog, which) -> {
                       // Handle negative button click
                   })
                   .setOnDismissListener(dialog -> isDialogShowing = false); // Update flag when dialog dismissed
            AlertDialog dialog = builder.create();
            dialog.show();
            isDialogShowing = true; // Update flag when dialog shown
        }
    }
}
Editor is loading...
Leave a Comment