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()
    不确定进度的对话框

猜你喜欢

转载自www.cnblogs.com/sixFlower/p/9283837.html