Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add on Change listener in Edittext

In my Android Application. i am having one EditText and Textview.in Edittext user need to enter the amount. while he entering the amount in edit text , in textview it has to display the total value (addition of tax value). How to do this.

like image 975
JK.C Avatar asked Oct 30 '25 13:10

JK.C


2 Answers

You can use textwatcher for that.

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) {

    }

    @Override
    public void afterTextChanged(Editable s) {

    }
});
like image 139
Orhan Obut Avatar answered Nov 02 '25 04:11

Orhan Obut


EditText Et = (EditText) findViewById(R.id.editTextID);
Et.addTextChangedListener(new TextWatcher() {
@Override
public void afterTextChanged(Editable s) {
    // TODO Auto-generated method stub
}

@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) {
    // TODO Auto-generated method stub
    // You need to write your code here when user need to enter the amount.
});
like image 44
Dhruv Avatar answered Nov 02 '25 03:11

Dhruv