W WDK Member Licensed User Nov 18, 2017 #1 I am trying to hide my banner when the edittext1 has focus and show my banner on end focus of edittext1. I get a true in the HasFocus boolean, but never a false. How can I determine if my edittext1 no longer has focus? Sub Activity_Create(FirstTime As Boolean) EditText1.InputType = EditText1.INPUT_TYPE_DECIMAL_NUMBERS End Sub Sub EditText1_FocusChanged (HasFocus As Boolean) ToastMessageShow(HasFocus,True) if HasFocus = True then Appodeal2.hide(Appodeal2.BANNER_BOTTOM) else Appodeal2.show(Appodeal2.BANNER_BOTTOM) end if End Sub
I am trying to hide my banner when the edittext1 has focus and show my banner on end focus of edittext1. I get a true in the HasFocus boolean, but never a false. How can I determine if my edittext1 no longer has focus? Sub Activity_Create(FirstTime As Boolean) EditText1.InputType = EditText1.INPUT_TYPE_DECIMAL_NUMBERS End Sub Sub EditText1_FocusChanged (HasFocus As Boolean) ToastMessageShow(HasFocus,True) if HasFocus = True then Appodeal2.hide(Appodeal2.BANNER_BOTTOM) else Appodeal2.show(Appodeal2.BANNER_BOTTOM) end if End Sub
Erel B4X founder Staff member Licensed User Longtime User Nov 19, 2017 #2 Please use [code]code here...[/code] tags when posting code. Most views never capture the focus. The focus will be lost if the user touches a different EditText. Provide a Done button and show the banner in the EnterPressed event. Upvote 0
Please use [code]code here...[/code] tags when posting code. Most views never capture the focus. The focus will be lost if the user touches a different EditText. Provide a Done button and show the banner in the EnterPressed event.
LucaMs Expert Licensed User Longtime User Nov 19, 2017 #3 Erel said: Most views never capture the focus. Click to expand... This is what I thought to answer, yesterday, adding also that you can make other views "focusable", using the reflection and the setFocusable method, but I tried this on a button and it changes its appearance (I have not investigated further ). Code: Sub SetFocusable(Vw As View, Focusable As Boolean) Dim R As Reflector R.Target = Vw R.RunMethod2("setFocusable", Focusable, "java.lang.boolean") R.RunMethod2("setFocusableInTouchMode", Focusable, "java.lang.boolean") End Sub BTW, without setFocusableInTouchMode, the method does not seem to work, at least when applied to a button. Upvote 0
Erel said: Most views never capture the focus. Click to expand... This is what I thought to answer, yesterday, adding also that you can make other views "focusable", using the reflection and the setFocusable method, but I tried this on a button and it changes its appearance (I have not investigated further ). Code: Sub SetFocusable(Vw As View, Focusable As Boolean) Dim R As Reflector R.Target = Vw R.RunMethod2("setFocusable", Focusable, "java.lang.boolean") R.RunMethod2("setFocusableInTouchMode", Focusable, "java.lang.boolean") End Sub BTW, without setFocusableInTouchMode, the method does not seem to work, at least when applied to a button.