Untitled
unknown
plain_text
2 years ago
937 B
6
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