nickk
06/11/2018, 10:10 AMPopupWindow
using anko
. However, my button handlers run as soon as the popup is presented, and the buttons do not respond to tapping. Any idea?
kotlin
private fun showAlert() {
// Get the Activity root view
val viewGroup = (findViewById<View>(android.R.id.content) as ViewGroup).getChildAt(0) as ViewGroup
val ui = AnkoContext.create(this)
val customView = with(ui) {
verticalLayout {
backgroundColor = Color.DKGRAY
padding = dip(10)
button("One") {
alert("Hi there") {
yesButton { }
}.show()
}
button("Two") {
longToast("Ooops")
}
}
}
val popup = PopupWindow(customView,
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT)
popup.showAtLocation(viewGroup, <http://Gravity.TOP|Gravity.TOP>, 0, 0)
}
gildor
06/11/2018, 11:09 AMonClick
inside buttonnickk
06/11/2018, 11:21 AM