You are not checking the value of HasFocus. The event first fires when EditText1 is focused and then when EditText1 loses focus.
Here is the code that I am actually using:
Sub EditTextWBLesson_FocusChanged (HasFocus AsBoolean)
IfPGDebugging4ThenLog(" +++ Begin of EditTextWBLesson_FocusChanged")
If HasFocus Then
IfPGDebugging4ThenLog("EditTextWBLesson_FocusChanged - Keyboard.HideKeyboard")
Keyboard.HideKeyboard
EndIf
IfPGDebugging4ThenLog(" --- End of EditTextWBLesson_FocusChanged")
IfPGDebugging4ThenLog(" ")
End Sub
I have always been checking the HasFocus variable. It does not work.
Next, I tried doubling-up that with this one:
Sub EditTextWBLesson_Click
IfPGDebugging4ThenLog(" +++ Begin of EditTextWBLesson_Click")
Keyboard.HideKeyboard
IfPGDebugging4ThenLog(" --- End of EditTextWBLesson_Click")
IfPGDebugging4ThenLog(" ")
End Sub
That method does not work in my particular situation.
It SOMETIMES works the first time you click on the keyboard.
The reason is... my program is doing intricate things in the background; there's no way you can ensure that their EditText box is going to keep focus for the entire time that the guy is typing.
Hidden in the background is a queue timer that checks the timer queue. As it counts-down, it writes that information to an EditText box in a completely different panel. It then writes more information into an EditText box in yet another panel.
So, will never be able to guarantee any focus will be constant on the EditText box the guy is working in. Therefore, I need to disable the KeyListener for their EditText box.
Tiny little examples which are in perfect worlds just don't work in the real word of Android programming. In the case of having the keyboard go-away, it just isn't yet being done in the right way.
I also have notifications being written from the service module, many different EditText boxes being updated constantly. Etc. Any intricate program does intricate things, and any method which stops the keyboard has to take all things such as that into account.
So, no, simple 'HasFocus' checks is going to keep the keyboard away, in my case. A complete disabling of the KeyListener for their EditText box is needed.