-3

I have a situation where there will be two EditText controls, one for entering Rate Before Tax value and another one for entering Rate After Tax. I will be changing both Rate BT and Rate AT values. When I change Rate BT, then Rate AT text should change depending on Rate BT and vice versa.

Please help

Sachin
  • 111
  • 1
  • 8
  • Can you post some code to help us to help you – Crammeur Aug 08 '18 at 07:01
  • 1
    It is possible to do it by setting two textwatchers for each edittexts; like... for Text2 : onTextChanged() { //change text 1 } For text1: onTextChanged() { //change text2 } – Papps Aug 08 '18 at 07:01

1 Answers1

1

You can simply do it as by adding TextWatcher to your edittext as,

rateAtEditText.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) {
             // you can do it here, what you want to do when RateAt text change
        }

        @Override
        public void afterTextChanged(Editable s) {

        }
    });

rateBtEditText.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) {
            // you can do it here, what you want to do when RateBt text change
        }

        @Override
        public void afterTextChanged(Editable s) {

        }
    });
Aditya
  • 3,525
  • 1
  • 31
  • 38