gpt4 book ai didi

android - 当编辑文本超过二十个时,如何知道我的编辑文本没有改变

转载 作者:太空宇宙 更新时间:2023-11-03 13:25:47 25 4
gpt4 key购买 nike

当我只有几个编辑文本时使用textchangeListener 或比较文本以查找文本是否已更改如果我有超过20 个edittext 如何知道编辑文本是否改变

我在这里发现几乎相同的问题 1。How to check if an EditText was changed or not? 2. Knowing when Edit text is done being edited这很有帮助......有任何简单的方法可以做到这一点。

String temp = "aa";
if(temp.equals(edittext.getText().toString()) {
Log.e("Not Change",temp);
} else {
Log.e("Changed Value",edittext.getText().toString());
}

提前致谢...

最佳答案

试试下面的方法:

编辑:

n1I1 = (EditText) findViewById(R.id.etN1I1);
n1I2 = (EditText) findViewById(R.id.etN1I2);
n1I3 = (EditText) findViewById(R.id.etN1I3);


TextWatcher textWatcher = new TextWatcher() {

@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

}

@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
Toast.makeText(yourActivity.this,"changed",0).show();
}

@Override
public void afterTextChanged(Editable editable) {

}
};

ArrayList<EditText> firstList = new ArrayList<EditText>();
firstList.add(n1I1);
firstList.add(n1I2);
firstList.add(n1I3);

for(int i=0;i<firstList.size();i++)
{
firstList.get(i).addTextChangedListener(textWatcher);
}

关于android - 当编辑文本超过二十个时,如何知道我的编辑文本没有改变,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20440278/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com