Android 如何将anko小部件添加到另一个anko小部件中?
与下面一样,如何将Android 如何将anko小部件添加到另一个anko小部件中?,android,kotlin,anko,Android,Kotlin,Anko,与下面一样,如何将customDialog添加到该警报 val customDialog = UI { verticalLayout{ padding = dip(16) val shortName = editText { hint = "Short name" textSize = 24f } val pwd
customDialog
添加到该警报
val customDialog = UI {
verticalLayout{
padding = dip(16)
val shortName = editText {
hint = "Short name"
textSize = 24f
}
val pwd = editText {
hint = "Password"
textSize = 24f
}
}
}
alert("Let me join in") {
customView {
verticalLayout {
customDialog
yesButton {
isCancelable = true
}
noButton { it.dismiss() }
}
}
}.show()
通过使用扩展函数
fun Context.customDialog() = verticalLayout {
padding = dip(16)
val shortName = editText {
hint = "Short name"
textSize = 24f
}
val pwd = editText {
hint = "Password"
textSize = 24f
}
}
alert("Let me join in") {
customView {
verticalLayout {
customDialog()
yesButton {
isCancelable = true
}
noButton { it.dismiss() }
}
}
}.show()
谢谢你的回答。已尝试,但警报中未显示任何内容:(