Not sure what I am doing wrong but in my CLV's I have a textbox which I want to only contain one character, That being the last one pressed.
I keep getting error:
I keep getting error:
Error occurred on line: 72 (B4XMainPage)
java.lang.ClassCastException: b4a.example.sd_keyboard cannot be cast to android.widget.EditText
at CKBTest.steward.b4xmainpage$ResumableSub_ETCutB_TextChanged.resume(b4xmainpage.java:317)
at CKBTest.steward.b4xmainpage._etcutb_textchanged(b4xmainpage.java:285)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
at anywheresoftware.b4a.BA$2.run(BA.java:395)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.app.ActivityThread.main(ActivityThread.java:8762)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:604)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)
B4XMainPage:
Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Private keys As String
Private lblcut As B4XView
Private ETCutA, ETCutB As EditText
Private clv, clvB As CustomListView
Private SD_Keyboard1 As SD_Keyboard
End Sub
Public Sub Initialize
' B4XPages.GetManager.LogEvents = True
End Sub
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
keys = "A,B,C,D"
SD_Keyboard1.SpecialKeyFont=xui.CreateMaterialIcons(16)
Dim Ck As CustomKey
Ck.Initialize
Ck.AddRowSimpleChar(Regex.Split(",",keys))
For i = 0 To 7
Dim p As B4XView = xui.CreatePanel("")
p.SetLayoutAnimated(0, 0, 0, 40dip, 40dip)
p.LoadLayout("clvRow")
lblcut.Text = i+1
lblcut.TextColor = xui.Color_Cyan
ETCutA.Text = "A"
SD_Keyboard1.Add(ETCutA,"ETCutA",Ck,Null)
clv.Add(p,i)
Next
For i = 0 To 7
Dim p As B4XView = xui.CreatePanel("")
p.SetLayoutAnimated(0, 0, 0, 40dip, 40dip)
p.LoadLayout("clvRowB")
lblcut.Text = i+1
lblcut.TextColor = xui.Color_Gray
ETCutB.Text = "B"
SD_Keyboard1.Add(ETCutB,"ETCutB",Ck,Null)
clvB.Add(p,i)
Next
End Sub
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
Private Sub Button1_Click
xui.MsgboxAsync("Hello world!", "B4X")
End Sub
Private Sub ETCutA_TextChanged (Old As String, New As String)
Dim edtxt As EditText = Sender
If New.Length > 1 Then
Sleep(0)
Dim ttt As String = New.SubString2(New.Length-1,New.Length)
edtxt.Text = ttt
edtxt.SetSelection(1,0)
End If
End Sub
Private Sub ETCutB_TextChanged (Old As String, New As String)
Dim edtxt As EditText = Sender
If New.Length > 1 Then
Sleep(0)
Dim ttt As String = New.SubString2(New.Length-1,New.Length)
edtxt.Text = ttt
edtxt.SetSelection(1,0)
End If
End Sub