If you want the Negative button to not execute any command when clicked, you can specify null
.setNegativeButton("Cancel", null)
or if we want to run stuff when Cancel is clicked
.setNegativeButton("Cancel") { dialog, which -> variable = true Toast.makeText(this, "Cancel hit!", Toast.LENGTH_SHORT).show()} .create()?.show()