2013-01-11 18 views
1

我有一个名为“text”的EditView。 我已经实现textWatcher无法将TextText设置为TextWatcher中的EditView

text.addTextChangedListener(this); 

每当我试图EditView中设置在TextWatcher一定的价值,它是扔强行关闭。

下面的代码:

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中必须重新设置为空。 请帮我一把。

+0

那么有什么错在那里这些意见?你可能想要实现'focusLost'监听器。 – GGrec

+2

显示你的logcat.and如果可能的话把你所有的代码 –

+0

它是一个TextView或EditText视图?用户在哪里输入值? – SKK

回答

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(); 
} 
+0

完美答案.. + 1 –

相关问题