I'm rendering the values from my database and placing those values in respective EditText field, so generally allowing the users to modify their save data.
I have a SAVE button on my page, where by default disabled. It should be enabled only when the EditText fields are really modified.
When comparing with the Database value,
- If the edit text value is changed - modified
- If the EditText Value is edited but not changed (user may copy paste the same value)- not modified.
Here is my code,
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) {}
};
Is there any way to compare the database value with current given value in EditText?
NOTE:
Since the TextWatcher function is common to all EditText, I want to do the comparison common.