欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

[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()

 

相关标签: anko alertDialog