Native Shopify Mobile App with 20 new features
Kickstart your hyperlocal marketplace in Corona pandemic with a starter guide
Android App Development
iOS App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 18.104.22.168 release ready!
Owner and Founder. Opencart
In android you can apply TextWatcher on an EditText and perform action based on changes in the EditText. It is particularly useful when you want to perform some action while the user is entering text like auto save feature of text or suggestion feature. So in that case we can apply a TextWatcher and attach the methods we want to perform on text change.
There are three methods of TextWatcher we can use based on our need.
a. beforeTextChanged( CharSequence s, int start, int count, int after )
This method is used to notify you that in the CharSequence s, count number of character that start at start are about to be changed with a new text having after number of characters.
b. onTextChanged( CharSequence s, int start, int before, int count)
It is just the reverse of earlier one. This method is used to notify you that in the CharSequence s, count number of character that start at start are already been changed with older text having before number of characters.
c. afterTextChanged(Editable s)
It is the mostly used method as it performs after the text is changed and we generally have to perform something when the text is changes like saving it for the user. Some people perform text changes in this method and if you do so be careful that you don’t end up in an infinite loop as after any change to the text this method is again called.
I had used it to save the value of the text so that the user always get the updated value and loss of the data can be prevented. Below is the dummy code:
Your email address will not be published. Required fields are marked*
Save my name email and website in this browser for the next time I comment.
Be the first to comment.
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.