[Anko]使用anko alert示例
程序员文章站
2022-07-12 10:52:13
...
alert { customView { verticalLayout { //对话框标题 toolbar { id = R.id.dialog_toolbar lparams(width = matchParent, height = wrapContent) backgroundColor = ContextCompat.getColor(ctx, R.color.colorAccent) title = "What's your next milestone?" setTitleTextColor(ContextCompat.getColor(ctx, android.R.color.white)) } val task = editText { hint = "To do task " padding = dip(20) } positiveButton("Add") { if(task.text.toString().isEmpty()) { toast("Oops!! Your task says nothing!") } else { adapter.add(task.text.toString()) showHideHintListView(todoList!!) } } } } }.show()
context?.alert("You are forced to be offline. Please try to login again.") { title = "Warning" isCancelable = false positiveButton("OK" ){ ActivityCollector.finishAll() context.startActivity<LoginActivity>() } }?.show()
上一篇: (转)[Kotlin]Null Safety空安全
下一篇: 批量修改表引擎 F#MySQL