-2

I have two edittext's amount and percentage. When I type amount in edittext percentage edittext should change and vice versa. How to achieve this?

Maharsh
  • 53
  • 5

1 Answers1

0

This is how you can achieve it.

EditText percentage = (EditText)findViewById(R.id.percentage);
EditText amount = (EditText)findViewById(R.id.amount);
amount.addTextChangedListener(new TextWatcher() {
    @Override
    public void afterTextChanged(Editable s) {
        // TODO Auto-generated method stub
    // calculate percentage and set it to percentage here
    }

    @Override
    public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        // TODO Auto-generated method stub
    }

    @Override
    public void onTextChanged(CharSequence s, int start, int before, int count) {

    } 
});
SRB Bans
  • 3,096
  • 1
  • 10
  • 21