我正在呈现数据库中的值,并将这些值放在相应的EditText字段中,因此通常允许用户修改他们的保存数据。
我的页面上有一个保存按钮,默认情况下是禁用的。只有当EditText字段真正被修改时,才应该启用它。
当与数据库值比较时,
这是我的密码
EditText text1 = (EditText) findViewById(R.id.text1);
EditText text2 = (EditText) findViewById(R.id.text2);
EditText text3 = (EditText) findViewById(R.id.text3);
EditText text4 = (EditText) findViewById(R.id.text4);
EditText text5 = (EditText) findViewById(R.id.text5);
ArrayList<EditText> editTextList = new ArrayList();
editTextList.add(text1);
editTextList.add(text2);
editTextList.add(text3);
editTextList.add(text4);
editTextList.add(text5);
for(EditText e : editTextList)
e.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中,有什么方法可以比较数据库值和当前给定值吗?
注意:
由于TextWatcher函数对所有EditText都是通用的,所以我想进行比较。
发布于 2017-06-05 10:07:24
你必须用一个全局变量来控制它。或响应对象或使用数据绑定。
https://stackoverflow.com/questions/44366413
复制相似问题