Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

change user entered character inside an EditText in Android

I want to change user entered character in a EditText. in fact i want when user types in Edit text, If input character is "S", replaces it with "B" character. i want do this realtime.

like image 446
Fcoder Avatar asked Jan 25 '26 21:01

Fcoder


1 Answers

I want to change user entered character in a EditText. in fact i want when user types in Edit text, If input character is "S", replaces it with "B" character. i want do this realtime.

Most likely you need to use TextWatcher that it pretty designated for your goal and allows you to manipulate with content of EditText in realtime.

Example:

edittext.addTextChangedListener(new TextWatcher() {

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

    }

    public void beforeTextChanged(CharSequence s, int start, int count, int after) {    

    }

    public void afterTextChanged(Editable s) {

    }
});
like image 113
Simon Dorociak Avatar answered Jan 27 '26 09:01

Simon Dorociak



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!