在项目中使用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]},对吗")
})

Android开发者的Anko使用指南(二之Dialogs-编程之家

Android开发者的Anko使用指南(二之Dialogs-编程之家

Progress dialogs

创建进度条对话框并显示

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

Android开发者的Anko使用指南(二之Dialogs-编程之家

不确定进度的对话框 indeterminateProgressDialog()
Android开发者的Anko使用指南(二之Dialogs-编程之家