how to make a custom alert in anko?
kotlin
val builder = AlertDialog.Builder(this, R.style.AlertDialogCustom)
val view = layoutInflater.inflate(R.layout.dialog_city, null)
view.findViewById<TextView>(R.id.tv_close).setOnClickListener {
btnShowDialog.isEnabled = true
dialog.cancel()
}
builder.setView(view)
dialog = builder.create()
dialog.setOnCancelListener(object : DialogInterface.OnCancelListener {
override fun onCancel(p0: DialogInterface?) {
btnShowDialog.isEnabled = true
}
})
dialog.show()
anko
alert {
layoutInflater.inflate(R.layout.dialog_city, null)
}.show()
tvClose.setOnClickListener how to do in anko?
You can add listeners as follows:
alert{
layoutInflater.inflate(R.layout.dialog_city, null)
}.setOnCancelListener(...).show()
it's a simple as
val alert = with(activity) {
alert {
customView = vertivalLayout {}
}
}
alert.show()
well, the theme where to enter the style file?
to Anko, how to set the theme of alert
Most helpful comment
it's a simple as
val alert = with(activity) { alert { customView = vertivalLayout {} } } alert.show()