title: Prevent backspace when there is only one character in EditText
body: <p>All- Sorry my title is so long I just couldn't find any other way to say it. So, I have an <code>EditText</code> and when there is only one character left (I can monitor it via a <code>TextWatcher</code>) I want to disable the backspace key. Here is what I have so far:</p>
  
  <pre><code>    editText$.addTextChangedListener(new TextWatcher() {
      private String current = "";
      String one = "1";   
      String empty = one; //Right now only set to "1" but want to set to "[any character]"
      public void onTextChanged(CharSequence s, int start, int before, int count) {       
      }
      public void afterTextChanged(Editable s) {
  
          if (s.toString().equals(empty)) {
              editText$.setOnKeyListener(new OnKeyListener() {                 
                  public boolean onKey(View v, int keyCode, KeyEvent event) {                 
                       if(keyCode == KeyEvent.KEYCODE_DEL){                        
                             return true; //Disable backspace key here
                           }                  
                  return false;       
                      }
              });         
          }       
      }
      public void beforeTextChanged(CharSequence s, int start, int count, int after) {
      }
    });
  </code></pre>
  
  <p>This works except for two key issues:</p>
  
  <p>1) I can only figure out how to check for a specific character ("1") versus any one character like I want to check for. I have tried <code>String empty = "1" + "2" + "etc";</code> but the code no longer works when I do that and plus, it seems like an inefficient way to do the task. </p>
  
  <p>2) When the <code>EditText</code> has something like 134 the backspace key gets disabled even though "1" is not the only character. Apparently if "1" is the fist character it doesnt matter what the rest are. This is my main problem. </p>
  
  <p>I know this is a lot to ask but any help you can give to help me solve these two issues would be greatly appreciated. Thanks.</p>