title: addTextChangedListener and onTextChanged are always called when Android Fragment loads
body: <p>I have an <code>EditText</code> in an Android <code>Fragment</code>. I attach <code>addTextChangedListener</code> to it in the <code>onCreateView</code> method. Within the <code>addTextChangedListener</code> I have an <code>onTextChanged</code> method. By logging, I can see that every time the <code>Fragment</code> is loaded, <code>onTextChanged</code> is called. Why would this be? I only want it to be called when the user actually changes the text in the <code>EditText</code>. Here's my code:</p>
  
  <pre><code>@Override
  public View onCreateView(final LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) {
  
      View view = inflater.inflate(R.layout.detailfragment, container, false);
      final EditText notes = (EditText)view.findViewById(R.id.stitchnotes);
  notes.addTextChangedListener(new TextWatcher() {
  
          @Override
          public void afterTextChanged(Editable s) {
          }
  
          @Override
          public void beforeTextChanged(CharSequence s, int start,
                  int count, int after) {
          }
  
          @Override
          public void onTextChanged(CharSequence s, int start,
                  int before, int count) {
              Edited = true;
          }
      });
  
      return view;
  }
  </code></pre>
  
  <p>I found <a href="https://stackoverflow.com/questions/13721063/aftertextchanged-callback-being-called-without-the-text-being-actually-changed">this post</a> and <a href="https://stackoverflow.com/questions/13303469/edittext-settext-not-working-with-fragment">this post</a> and I'm wondering if I should move my code to <code>onResume</code>. However, as you can see from the above code, I need access to the <code>LayoutInflater</code> and <code>ViewGroup</code> passed to <code>onCreateView</code> in order to access the <code>EditText</code>; however, <code>onResume</code> doesn't normally have access to these items. Should I be using <code>onResume</code>? How do I handle the issue with the <code>LayoutInflater</code> and <code>ViewGroup</code>?</p>
  
  <p>-----------------Further Information----------------------</p>
  
  <p>I used Tyler's answer to solve the problem of how to use <code>onResume</code>, but onTextChanged is still being called when I first open the <code>Fragment</code>. Can someone explain why?  Here's my modified code:</p>
  
  <pre><code>private EditText notes;
  @Override
  public View onCreateView(final LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) {
  
      View view = inflater.inflate(R.layout.detailfragment, container, false);
      notes = (EditText)view.findViewById(R.id.stitchnotes);
      return view;
  }
  
  @Override
  public void onResume() {
      super.onResume();
      notes.addTextChangedListener(new TextWatcher() {
  
          @Override
          public void afterTextChanged(Editable s) {
          }
  
          @Override
          public void beforeTextChanged(CharSequence s, int start,
                  int count, int after) {
          }
  
          @Override
          public void onTextChanged(CharSequence s, int start,
                  int before, int count) {
              Edited = true;
              Log.w("onTextChanged","Here");
          }
      });
  }
  
  &lt;EditText
          android:id="@+id/stitchnotes"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:layout_weight="1"
          android:gravity="left"
          android:hint="@string/hint"
          android:textAppearance="?android:attr/textAppearanceSmall"
          android:inputType="text"
          android:visibility="invisible"
          android:textSize="30dip" /&gt;
  </code></pre>
  
  <p>The moment I open the <code>Fragment,</code> <code>Edited</code> is set to true and the LogCat is written to. I don't want this. I want <code>Edited</code> to be set to true only when the user actually types something in the <code>EditText</code>. What am I doing wrong?</p>