Answers for "how to create delete alert in android studio kotlin"

0

how to create delete alert in android studio kotlin

myView.deleteBtn.setOnClickListener {
    val builder = AlertDialog.Builder(this@MainActivity)
    builder.setMessage("Are you sure you want to Delete?")
        .setCancelable(false)
        .setPositiveButton("Yes") { dialog, id ->
            // Delete selected note from database
            var dbManager = DbManager(this.context!!)
            val selectionArgs = arrayOf(myNote.nodeID.toString())
            dbManager.delete("ID=?", selectionArgs)
            LoadQuery("%")
        }
        .setNegativeButton("No") { dialog, id ->
            // Dismiss the dialog
            dialog.dismiss()
        }
    val alert = builder.create()
    alert.show()
}
Posted by: Guest on April-12-2022

Code answers related to "how to create delete alert in android studio kotlin"

Browse Popular Code Answers by Language