Project RoboMVVM(https://github.com/debdattabasu/RoboMVVM)
Copyright (c) 2014, Debdatta Basu
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are ...
If you think the Android project RoboMVVM listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package org.dbasu.robomvvm.samples.textsync_no_mvvm;
/*fromwww.java2s.com*/import android.app.Activity;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.widget.EditText;
publicclass MainActivity extends Activity {
EditText text0, text1;
privatefinal TextWatcher watcher0 = new TextWatcher() {
@Override
publicvoid beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
publicvoid onTextChanged(CharSequence s, int start, int before, int count) {
text1.removeTextChangedListener(watcher1);
text1.setText(text0.getText().toString());
text1.addTextChangedListener(watcher1);
}
@Override
publicvoid afterTextChanged(Editable s) {
}
};
privatefinal TextWatcher watcher1 = new TextWatcher() {
@Override
publicvoid beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
publicvoid onTextChanged(CharSequence s, int start, int before, int count) {
text0.removeTextChangedListener(watcher0);
text0.setText(text1.getText().toString());
text0.addTextChangedListener(watcher0);
}
@Override
publicvoid afterTextChanged(Editable s) {
}
};
@Override
protectedvoid onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
text0 = (EditText) findViewById(R.id.edit_text_0);
text1 = (EditText) findViewById(R.id.edit_text_1);
text0.addTextChangedListener(watcher0);
text1.addTextChangedListener(watcher1);
}
}