在項目中使用
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]},對嗎")
})
Progress dialogs
創建進度條對話框並顯示
val progressDialog = progressDialog(message="請稍等...",title="文件下載中")
- 不確定進度的對話框
indeterminateProgressDialog()