title: Android EditText InputFilter not working
body: <p>I have an <code>EditText</code>, accepts chars except whitespace, I use an <code>InputFilter</code> to filter the input chars, and a <code>InputFilter</code> to constrain the length of the input, but the <code>InputFilter</code>s do not all work.</p>
  
  <p>My full code is something like below: <code>initBodyView()</code> is the entrance of the activity</p>
  
  <pre><code>public class MainActivity extends CustomedActivity{
  
  
  InputFilter mcFilter = new InputFilter() {
  
      @Override
      public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
          for (int i = start; i &lt; end; i++) {
              if (Character.isSpaceChar(source.charAt(i))) {
                  // do something
                  return "";
              }
          }
          return null;
      }
  };
  
  
  private TextWatcher mcTextWatcher = new TextWatcher() {
  
      @Override
      public void beforeTextChanged(CharSequence s, int start, int count, int after) {
          // TODO Auto-generated method stub
          if (mVinLimit &lt;= INPUT_LOWER_LIMIT) {
              mcFlag = true;
          }
  
      }
  
      @Override
      public void onTextChanged(CharSequence s, int start, int before, int count) {
          // TODO Auto-generated method stub
      }
  
      @Override
      public void afterTextChanged(Editable s) {
          // TODO Auto-generated method stub
          if (mVinLimit &gt; INPUT_LOWER_LIMIT &amp;&amp; mVinLimit &lt; INPUT_UPPER_LIMIT) { 
              if (s.length() == mVinLimit) {
                  mcFlag = true;
              } else {
                  mcFlag = false; 
              }
          } else if (INPUT_UPPER_LIMIT == mVinLimit) { 
              if (s.length() &gt; 0) {
                  mcFlag = true;
              } else {
                  mcFlag = false;
              }
          }
  
      }
  };
  
  
  
  // the entrance of the activity
  @Override
  protected void initBodyView() {
      mBodyView = inflate(R.layout.layout);
      mc = (EditText)mBodyView.findViewById(R.id.mc);
      mc.addTextChangedListener(mcTextWatcher);
      mc.setFilters(new InputFilter[] {
              new InputFilter.LengthFilter(INPUT_LIMIT), mcFilter
      });
  }
  </code></pre>
  
  <p>}</p>
  
  <p><strong>the second <code>InputFilter</code> does not work</strong></p>
  
  <p>the attributes of the <code>EditText</code> is as follows:</p>
  
  <pre><code>&lt;EditText
  android:id="@+id/carriage_number"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:layout_centerVertical="true"
  android:inputType="textUri"
  android:singleLine="true" &gt;
  &lt;/EditText&gt;
  </code></pre>