Android Question ViewsEx Events cause program crash

epsharp

Member
Licensed User
Longtime User
B4X:
Sub t1.EnterPressed
    Dim who As FloatLabeledEditText
    who = Sender
    Log(who)

I have 6 different fields all using [ t1 ] as the event. The above code, to determine which field it was, caused the following:

psssq_t1_enterpressed (java line: 1158)
java.lang.ClassCastException: android.widget.EditText cannot be cast to com.wrapp.floatlabelededittext.FloatLabeledEditText
at b4a.ProActivePOS.psssq._t1_enterpressed(psssq.java:1158)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:186)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:170)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:166)
at anywheresoftware.b4a.objects.EditTextWrapper$2.onEditorAction(EditTextWrapper.java:107)
at android.widget.TextView.onEditorAction(TextView.java:6603)
at com.android.internal.widget.EditableInputConnection.performEditorAction(EditableInputConnection.java:138)
at com.android.internal.view.IInputConnectionWrapper.executeMessage(IInputConnectionWrapper.java:360)
at com.android.internal.view.IInputConnectionWrapper$MyHandler.handleMessage(IInputConnectionWrapper.java:85)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6938)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)


The same code for the FocusChanged Event works fine. Any assistance would be appreciated.

Ed Sharp
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
I guess that you meant to write:
B4X:
Sub T1_EnterPressed
The EnterPressed event comes directly from the internal EditText.

You can do something like this:
B4X:
Sub Activity_Create
 'load layout and then
T1.EditText.Tag = T1 'T1 is FloatLabeledEditText
End Sub

Sub T1_EnterPressed
 Dim et As EditText = Sender
 Dim ft as FloatLabeledEditText = et.Tag
 
Upvote 0
Top