无法将TextText设置为TextWatcher中的“编辑视图”

时间:2013-01-11 12:08:22

标签: java android textview textwatcher

我有一个名为“text”的EditView。 我已经实现了textWatcher

   text.addTextChangedListener(this);

每当我尝试将EditView设置为TextWatcher中的某个值时,它就会强制关闭Force。

以下是代码:

 public void beforeTextChanged(CharSequence s, int start, int count,int after) 
 {

  }
 public void onTextChanged(CharSequence s, int start, int before, int end)
  {
//text.setText("");
    }
   public void afterTextChanged(Editable s)
{       
     //text.setText("");
}

我的要求是:每当用户键入一些值时,EditView必须设置回Null。 请帮帮我。

1 个答案:

答案 0 :(得分:1)

你可以这样做:

public void beforeTextChanged(CharSequence s, int start, int count,int after) {
}

public void onTextChanged(CharSequence s, int start, int before, int end) {
}

public void afterTextChanged(Editable s){       
    s.clear();
}