如何检查是否一个EditText已更改或不呢? [英] How to check if an EditText was changed or not?

查看:133
本文介绍了如何检查是否一个EditText已更改或不呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要知道,如果一个的EditText 改变与否,不在于是否用户输入的领域的一些文字,但只有当字符串被改变。

I need to know if an EditText was changed or not, not whether or not the user inputted some text in the field, but only the if String was changed.

推荐答案

您需要 TextWatcher

在这里看到它在行动:

EditText text = (EditText) findViewById(R.id.YOUR_ID);
text.addTextChangedListener(textWatcher);


private TextWatcher textWatcher = new TextWatcher() {

  public void afterTextChanged(Editable s) {
  }

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

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

  }
}

这篇关于如何检查是否一个EditText已更改或不呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆