在项目中使用
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")
toastR.string.message)
longToast"hello anko")
SnackBar
snackbarview, "Hi anko!")
snackbarview, R.string.message)
longSnackbarview, "Wow, such duration")
snackbarview, "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实现
alertAppCompat,"message").show)
自定义
alert{
customView{
editText)
}
}.show)
Selector
var log = listOf"android","kotlin","ios")
selector"你的技能",log,{
dialogInterface, i -> toast"你现在会${log[i]},对吗")
})
Progress dialogs
创建进度条对话框并显示
val progressDialog = progressDialogmessage="请稍等...",title="文件下载中")