Android Question TextChanged event

andrewmp

Member
Licensed User
Longtime User
I'm trying to a datalist with rows that contains a textbox

Sub DataEditText_TextChanged (Old, New)

Dim index As Int = datalist2.GetItemFromView(Sender)

Dim pnl As Panel
pnl = datalist2.GetPanel(index)
Dim txt As EditText
txt=pnl.GetView(0)

It does not work - it seems that sender is not sent, does anyone know of a way to decode which DataEditText sent the change?

Thanks in advance
 

klaus

Expert
Licensed User
Longtime User
Unfortunately, you don't give enough information !
I suppose that datalist is a class.
How do you define the EditTexts ?
Where is the Sub DataEditText_TextChanged (Old, New) event routine ?
Do you set the Tag property of the EditTexts ?
Is GetItemFromView a function in your class ?
etc.

As you are using a specific event for EditTexts, Sender is the EditText that raised the event.
So, this should work:
B4X:
Dim txt As EditText
txt = Sender
Best regards.
 
Upvote 0

andrewmp

Member
Licensed User
Longtime User
Thanks for the prompt reply, here is the rest:

Sub CreateDataListItem2(row As Int,editable As Int,texts() As String,objtype As Int, Width As Int, Height As Int) As Panel
Dim p As Panel
Dim textsize As Int

textsize=17
p.Initialize("datapanel")
p.Color = Colors.rgb(173,216,230)
Dim lbl As Label
lbl.Initialize("")
lbl.Gravity = Bit.OR(Gravity.CENTER_VERTICAL, Gravity.LEFT)
lbl.text = texts(0)
lbl.textsize = textsize
lbl.TextColor = Colors.Black
lbl.Tag=editable

Dim lbl2 As Label
lbl2.Initialize("")
lbl2.Gravity = Bit.OR(Gravity.CENTER_VERTICAL, Gravity.LEFT)
lbl2.text = texts(0)
lbl2.textsize = textsize
lbl2.TextColor = Colors.Black
lbl2.text=texts(1)
p.AddView(lbl, 2dip, 2dip, 130dip, Height - 4dip) 'view #0

If objtype=0 Then ' text
Dim txt As EditText
txt.Initialize("DataEditText")
txt.textsize = textsize
txt.Wrap=False
txt.TextColor = Colors.Black
txt.Color=Colors.white
txt.text=texts(2)
txt.Tag=row
If IsNumber(texts(3)) Then
txt.InputType=txt.INPUT_TYPE_DECIMAL_NUMBERS
End If
If editable=0 Then
txt.Enabled=False
Else
txt.Enabled=True
End If
p.AddView(txt, 135dip, 2dip, 100dip,39dip) 'view #1
Else If objtype=1 Then ' combo

End If

p.AddView(lbl2,2dip, 40dip, 475dip,39dip) 'view #2
Return p

End Sub

Need to get txt.Tag somehow on TextChanged event...
 
Upvote 0

andrewmp

Member
Licensed User
Longtime User
I had tried it , the real problem was I had to invert

txt.Tag=row
txt.text=texts(2)

As the TextChange event was getting called on init. and tag did not exist

Thanks for the help, I was worried the Sender was not available
 
Upvote 0
Top