Android Question Why can't I replace text in edittext in clv when using SD_CustomKeyboard

tsteward

Well-Known Member
Licensed User
Longtime User
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:

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
 

Attachments

  • TS_Test.zip
    13 KB · Views: 44

tsteward

Well-Known Member
Licensed User
Longtime User
Additionally once text in an edittext has been set how can I set focus to the edittext in the next row(column)
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
Please explain
Wrong = incorrect

The event is not raised by the native object but by the CustomKeyboard and therefore that is the sender. I advise you against putting a unique event for several EditTexts, as you would create complications in recognizing them

try this
B4X:
Dim ob as Object = Sender
Lof(GetType(ob))
 
Last edited:
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
B4X:
    Dim view As B4XView = Sender
    Log(view)
What do you see in the log panel?
This will generate an error. The sender is not a b4xview
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…