title: Differences between TextWatcher 's onTextChanged, beforeTextChanged and afterTextChanged
body: <p>In my Android project, I have had to add a <strong>TextChangedListener</strong> (TextWatcher) to an edit text view. And there are three parts to it:</p>
  
  <ul>
  <li><code>onTextChanged()</code> </li>
  <li><code>beforeTextChanged()</code> </li>
  <li><code>afterTextChanged()</code></li>
  </ul>
  
  <p>What are the differences of these three? I have had to implement a search of a table on the key listener and for my case all these three looked the same. Also they functioned the same. When I input a part of a product name, the table redraws with only those products that contain entered text in it. But I used the <code>afterTextChanged()</code> part. My code is:</p>
  
  <pre><code>EditProduct.addTextChangedListener(new TextWatcher() {
  
          @Override
          public void onTextChanged(CharSequence s, int start, int before,
                  int count) {
              // TODO Auto-generated method stub
  
              // System.out.println("onTextChanged"+s);
          }
  
          @Override
          public void beforeTextChanged(CharSequence s, int start, int count,
                  int after) {
              // TODO Auto-generated method stub
              // System.out.println("beforeTextChanged"+s);
          }
  
          @Override
          public void afterTextChanged(Editable s) {
              // TODO Auto-generated method stub
              // System.out.println("afterTextChanged"+s);
  
              String new_prx = s.toString();
  
              System.out.println(s);
              mini_productList = new ArrayList&lt;Product&gt;();
  
              // mini_productList
              int count = 0;
              if (new_prx.equals("")) {
  
                  loadtableProducts(productList);
  
              } else {
  
                  for (int i = 0; i &lt; productList.size(); i++) {
  
                      if (productList.get(i).getDescription().toString()
                              .substring(0, (new_prx.length()))
                              .equalsIgnoreCase(new_prx)) {
                          mini_productList.add(productList.get(i));
                          count++;
  
                      }
                  }
  
                  loadtableProducts(mini_productList);
              }
          }
      });
  </code></pre>
  
  <p>So can someone give me an explanation on these three?</p>