Android Question Fail to assign a tag to an initialized edittext

Discussion in 'Android Questions' started by catyinwong, Apr 3, 2015.

  1. catyinwong

    catyinwong Active Member Licensed 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???? ><
     
  2. klaus

    klaus Expert Licensed 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
     
  3. catyinwong

    catyinwong Active Member Licensed 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... :(
     
  4. catyinwong

    catyinwong Active Member Licensed 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.
     
  5. klaus

    klaus Expert Licensed User

    You should post a small project showing the problem as a zip file (IDE menu File / Export As Zip).
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice