if we have two edittextviews and change the value in one edittextview the value of the other automatically change dynamically.For example if i have a currency converter and when i try to put the dollar value the other edittext value change with respect to dollar value at the same time.
Asked
Active
Viewed 142 times
0
-
3search about ontextchangelistener https://stackoverflow.com/questions/12191394/change-edittext-text-from-ontextchangelistener – Roljhon Dec 14 '17 at 15:16
1 Answers
1
In this case, you need to add a TextChangeListener to the first edittext field from which second edittext is taking its input.
firstEdText.addTextChangedListener(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) {
String input = charSequence.toString(); // This is the text entered in your firstEdittext
secondEdText.setText(charSequence);
}
@Override
public void afterTextChanged(Editable editable) {
}
});

Pratik Mhatre
- 779
- 7
- 12