I have a 7x6 grid of EditText
views. I want all of them disabled when the application starts, ie they should behave like normal TextViews
and not to be editable. Then the user taps one cell in the grid, it changes its background and performs something visual. If the user clicks on the cell one more time it should allow editing. I'm struggling with OnClick()
and OnFocusChange()
listeners, but I can't accomplish such a basic interaction.
Playing with setEnabled()
and setFocusable()
doesn't help. I wonder why even a simple task like this has been made so difficult on Android
I finally found a solution. It's a matter of calling
setFocusableInTouchMode(boolean)
setFocusable(boolean)
when the EditText
is first created, so it can intercept the clicks. Then one can set those flags back again to make the EditText
editable, request the focus, and manually show/hide the soft keyboard with InputMethodManager
methods
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With