I am making a converter app that converts rupees to dollar and vice versa,i want to use two edit text only, i want it to work as when i enter a value in the edit text meant for rupees it should simultaneously show the converted value in the edit text meant for dollar, to be more precise i want that if i want to convert 120 rupees to dollar, as i start entering 120, as 1 it should show the converted value simultaneously in the dollar edit text, followed by 12 and then finally 120.
I have tried-
if(editText.isFocusable()==true){
editText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
str=editText.getText().toString();
rs = Double.parseDouble(str);
rstodol = rs / 65;
str1 = Double.toString(rstodol);
editText1.setText(str1);
}
@Override
public void afterTextChanged(Editable s) {
}
});
}
else if(editText1.isFocusable()==true){
editText1.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
str=editText1.getText().toString();
dol=Double.parseDouble(str);
doltors=dol*65;
str2=Double.toString(doltors);
editText.setText(str2);
}
@Override
public void afterTextChanged(Editable s) {
}
});
}
where am i wrong ?