Bug: Disabled Edit Views Still Get Focus

Roger Garstang

Well-Known Member
Licensed User
Longtime User
That is the link I posted in the thread. In Android 3+ they fixed the part where typing in it was allowed...but they appear to have left the focusable status up to the developer. I think the code for the enabled status on Edit Boxes and possibly views in general needs some additional code to set the Focusable status of the view for both keyboard and touch along with enabled to completely disable the control and then re-enable them all when enabled=true. A disabled control shouldn't be allowed to get focus by keyboard or touch. There is a comment in that thread discussing those methods and about restoring focusable when enabled.

Is there a way to call the two focusable methods using the reflection stuff or something? Then it can be tested to see if it makes a difference. I think if we can fix the ability to get focus it would prevent typing in them on Android versions before 3.x.
 

Roger Garstang

Well-Known Member
Licensed User
Longtime User
Ok, it looks like that fixed it, although I had to use setFocusableInTouchMode. What exactly is the difference between setFocusableInTouchMode and setFocusable? Does it apply to devices with hardware keyboards vs. touchscreen only?

setFocusable worked to disable the focus on the control that prevented the keyboard from giving it focus and most likely the other thread's TabHost focus problem too (untested). Setting it and enabled back to true though didn't get the control full functional again- tapping gave focus then took it away and the keyboard next still skipped it.

Using setFocusableInTouchMode instead toggled it exactly how expected. May want to test it on a device with a hardware keyboard though since it appears that there are 2 focusable toggles- one for keyboard and one for touch. setFocusable appears to turn off both, but only turns on one. setFocusableInTouchMode appears to turn off at least one and turns on the one needed for my device. Doesn't seem to hurt to use both too.
 
Top