Android開發者的Anko使用指南(二)之Dialogs


在項目中使用Anko Dialogs

dependencies {
compile "org.jetbrains.anko:anko-commons:$anko_version"
compile "org.jetbrains.anko:anko-design:$anko_version" // For SnackBars
}

Toasts

toast("hello anko")
toast(R.string.message)
longToast("hello anko")

SnackBar

snackbar(view, "Hi anko!")
snackbar(view, R.string.message)
longSnackbar(view, "Wow, such duration")
snackbar(view, "Action, reaction", "Click me!") { doStuff() }

Alerts Dialog

  • 默認的alert dialog

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

  • 使用appcompat實現

    alert(AppCompat,"message").show()

  • 自定義

    alert{
    customView{
    editText()
    }
    }.show()

Selector

 var log = listOf("android","kotlin","ios") 
selector("你的技能",log,{
dialogInterface, i -> toast("你現在會${log[i]},對嗎")
})

selector

selector點擊后

Progress dialogs

創建進度條對話框並顯示

val progressDialog = progressDialog(message="請稍等...",title="文件下載中")

進度條對話框

  • 不確定進度的對話框 indeterminateProgressDialog()
    不確定進度的對話框


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM