Android Question How to force an EditText to loose the focus ?

LucaMs

Expert
Licensed User
Ah, bene, sei italiano, non snobbare il forum italiano grrrrrrr :)

Spostando il focus su un'altra EditText, ad esempio, magari non visibile.

By setting the focus on another EditText, maybe invisible.
 

marcick

Well-Known Member
Licensed User
Yes, I already tried that trick, but if the control is invisible it does not accept the focus.
Also if I set it visible and move it off-screen, let's say .left=10000 it does not accept focus.
(ciao Luca, non snobbo nessuno ma qua siamo in tanti !)
 

fixit30

Active Member
Licensed User
Yes, I already tried that trick, but if the control is invisible it does not accept the focus.
Also if I set it visible and move it off-screen, let's say .left=10000 it does not accept focus.
It does look like if the EditText is not Visible then it will not accept focus, however with my Sample attached it DOES work if the EditText is off the screen. If you look at the Layout file in the designer and set zoom to 50% you will see the second EditText.
 

Attachments

mangojack

Well-Known Member
Licensed User
I have used this workaround a few times .. and agree with @fixit30 that it works if the ET is off screen.
In the Designer EditText is set to ..
B4X:
Visible = True
Enabled = False
and hidden beneath another view (Send to Back in the Designer)
When needed I call
B4X:
  edtTakeFocus.RequestFocus
 

marcick

Well-Known Member
Licensed User
Hi all,
I don't know why fixit30 sample was working and the same trick on my project not. I have removed my EdtTexts and added again, now it behaves as desired.
Thanks everybody
Marco
 
Top