Android Alert Dialog .setNegativeButton

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()}

Leave a Reply

Your email address will not be published. Required fields are marked *