I'm going to create a dialog with the delete button printed on it, "Are you sure you want to delete this?"
If you press the delete button, the data will be deleted, and if you don't, nothing will happen, but I made this button click listener, but I can't add it to the dialog... What do I do?
android android-dialog
new AlertDialog.Builder(context)
.setTitle("Delete entry")
.setMessage ("Are you sure you want to delete this?")
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// Click this button to proceed with deletion
}
})
.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// Nothing's happening
}
})
.setIcon(android.R.drawable.ic_dialog_alert)
.show();
Try applying this.
© 2024 OneMinuteCode. All rights reserved.