How do I display an alert dialog on Android?

后端 未结 30 3071
清歌不尽
清歌不尽 2020-11-22 03:02

I want to display a dialog/popup window with a message to the user that shows \"Are you sure you want to delete this entry?\" with one button that says \'Delete\'. When

30条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-22 03:30

    With Anko (official library from developers of Kotlin), you can simple use

    alert("Alert title").show()
    

    or more complex one:

    alert("Hi, I'm Roy", "Have you tried turning it off and on again?") {
        yesButton { toast("Oh…") }
        noButton {}
    }.show()
    

    To import Anko:

    implementation "org.jetbrains.anko:anko:0.10.8"
    

提交回复
热议问题