Inline onFocusChange kotlin
You simply forgot to call hasFocus
:
setOnFocusChangeListener(View.OnFocusChangeListener { view, b -> hasFocus(b) })
/\/\/\/\/\
This is a sweet and readable syntax:
yourEditText.setOnFocusChangeListener { _, hasFocus ->
if (hasFocus)
showSomething()
else
hideSomething()
}
Just to clarify, there isn't really a point in creating an inline method extension. This was my initial objective but I later realized that using:
editText.setOnFocusChangeListener { view, b -> doSomething(b) }
was possible, it's inline, it's pretty and no extra work is needed