Android Question IME SoftKeyBoard - Done Event

Declan

Well-Known Member
Licensed User
Longtime User
I am using this example to incorporate the IME "Done" Event:

B4X:
Sub Globals
Private txtEvents As EditText
Dim IME As IME

B4X:
Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("CalendarCLV")
  
    IME.Initialize("IME")
    IME.AddHandleActionEvent(txtEvents)

B4X:
Sub IME_HandleAction As Boolean
    Dim e As EditText
    e = Sender
    If e.Text.StartsWith("a") = False Then
        ToastMessageShow("Text must start with 'a'.", True)
        'Consume the event.
        'The keyboard will not be closed
        Return True
    Else
        Return False 'will close the keyboard
    End If
End Sub

I receive this error and cannot understand as the EditText (txtEvents) has bee initialized?
B4X:
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Error occurred on line: 72 (Main)
java.lang.RuntimeException: Object should first be initialized (EditText).
    at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:50)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:708)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:337)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:247)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
    at b4a.example.main.afterFirstLayout(main.java:102)
    at b4a.example.main.access$000(main.java:17)
    at b4a.example.main$WaitForLayout.run(main.java:80)
    at android.os.Handler.handleCallback(Handler.java:815)
    at android.os.Handler.dispatchMessage(Handler.java:104)
    at android.os.Looper.loop(Looper.java:194)
    at android.app.ActivityThread.main(ActivityThread.java:5631)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
** Activity (main) Resume **
 
Top