title: Android afterTextChanged get EditText tag
body: <p>I have a <code>DialogFragment</code> containing a <code>ListView</code>, with a custom adapter hooked up to the <code>ListView</code>. The list displays a bunch of items with an <code>EditText</code> for each record to allow the user to enter a quantity.</p>
  
  <p>When any of these quantities change I need to update my array within the adapter, which means linking an <code>EditText</code> to a specific element in the array. I do this using the getTag / setTag methods of the <code>EditText</code>. Items in the array are unique by two properties:</p>
  
  <p><code>LocationID</code>and
  <code>RefCode</code></p>
  
  <p>These are stored in my <code>TagData</code> object and set at the point of getView(). I'm attempting to use <code>EditText.getTag()</code> once a value has changed, sadly to no avail. </p>
  
  <p>The problem is I can't access the <code>EditText</code> in the <code>afterTextChanged</code> method. </p>
  
  <p>Here's the <code>getView()</code> method of my Adapter:</p>
  
  <pre><code>@Override
  public View getView(int i, View view, ViewGroup viewGroup) {
  
      ItemModel item = (ItemModel) getItem(i);
  
      TagData tagData = new TagData();
      tagData.setLocationID(item.getLocationID());
      tagData.setRefCode(item.getRefCode());
  
      EditText txtQuantity = ((EditText) view.findViewById(R.id.txtQuantity));
      txtQuantity.setTag(tagData);
      txtQuantity.setText(String.valueOf(item.getQtySelected()));
  
      txtQuantity.addTextChangedListener(this);
      ...
      return view;
  }
  </code></pre>
  
  <p>Above I create a <code>TagData</code> object and tie it to the <code>EditText</code> using <code>setTag()</code>. I also hook up an <code>addTextChangedListener</code> in the <code>getView()</code>. For which the <code>afterTextChanged</code> method looks like this:</p>
  
  <pre><code>@Override
  public void afterTextChanged(Editable editable) {
      EditText editText = (EditText)context.getCurrentFocus(); // This returns the WRONG EditText!?
  
      // I need this 
      TagData locAndRefcode = (TagData) editText.getTag();
  }
  </code></pre>
  
  <p>According to <a href="https://stackoverflow.com/a/5951792/513450">this</a> post, <code>Activity.getCurrentFocus()</code> should return the <code>EditText</code> in question, it doesn't. Instead it returns an <code>EditText</code> from the View behind the DialogFragment.</p>
  
  <p>Which leaves me stuck. How can I get access to an <code>EditText</code>'s tag from within my afterTextChanged method?</p>