How to clear the text in edittext

2019-04-20 21:04发布

I want to clear the text in EditText after it has been saved in database.

Here is my code:

pictureDescription.addTextChangedListener(new TextWatcher()
{
  public void afterTextChanged(Editable textValue)
  {
    String content = textValue.toString();
    db.updatePicDes(content,lastSnapId);

  }
}

6条回答
地球回转人心会变
2楼-- · 2019-04-20 21:17
pictureDescription.addTextChangedListener(new TextWatcher() {
   public void  afterTextChanged(Editable textValue) { 
          String content = textValue.toString(); 
          db.updatePicDes(content,lastSnapId);
           pictureDescription.setText("");
   }
}
查看更多
孤傲高冷的网名
3楼-- · 2019-04-20 21:21

you can use EditText.setText("");

查看更多
萌系小妹纸
4楼-- · 2019-04-20 21:22

Just set it to empty string. I think it should do it.

EditText editText = (EditText)findViewById(R.id.edit_text);
editText.setText("");
查看更多
做自己的国王
5楼-- · 2019-04-20 21:29

Use editText.getText().clear().

查看更多
放我归山
6楼-- · 2019-04-20 21:29

You better do that in FocusChangedListener if you donot want it on clicking a button.

查看更多
贪生不怕死
7楼-- · 2019-04-20 21:37
String content = textValue.toString();
db.updatePicDes(content,lastSnapId);
editText.setText("");
查看更多
登录 后发表回答