Android Question Fail to assign a tag to an initialized edittext

catyinwong

Active Member
Licensed User
Longtime User
Here is the code I use to initialize an edittext and assign the tag
<code>
Dim EditText1 as EditText
EditText1.Tag = m.get("Name") 'm is a map which I have put information in advance
EditText1.Text = m.get("Phone Number")
DesignPanel.Panel.AddView(EditText1,30%x,10,70%x,80)
</code>

When the EditText_TextChanged raised, a messagebox will pop up so that I can check if the tag is correctly assigned. But when it was raised by the code above (When the phone number is put automatically), the tag appears to be okay. However, the tag becomes null when it is raised by myself changing the text manually.

<code>
Sub EditText1_TextChanged (Old As String, New As String)
Dim ET1 As EditText = Sender
Dim key As String = ET1.Tag
Msgbox("Tag = " & Key,"")
</code>

Why is that???? ><
 

klaus

Expert
Licensed User
Longtime User
It seems that your are adding EditText1 in the code, so you need to initialize it.
EditText1.Initialize("EditText1").
If EditTExt1 is the only view raising the Sub EditText1_TextChanged event you can replace:
Dim ET1 As EditText = Sender
Dim key As String = ET1.Tag

by
Dim key As String = EditText1.Tag
 
Upvote 0

catyinwong

Active Member
Licensed User
Longtime User
I have initialized the Edittext but forgot to put it here.
And in fact I have added several EditText1 in different codes (basically the same codes) so I need to address the sender for this.

So these two should not be the solution... :(
 
Upvote 0

catyinwong

Active Member
Licensed User
Longtime User
And the true confusing part is that the textchanged event is raised when the text is automatically changed in the above code, but it isn't raised when I type in texts manually.
 
Upvote 0
Top