Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Knowing when Edit text is done being edited

How do I know when my edit text is done being edited? Like when the user selects the next box, or presses the done button on the soft keyboard.

I want to know this so I can clamp the input. It looks like text watcher's afterTextChanged happens after each character is entered. I need to do some calculations with the input, so I would like to avoid doing the calculation after each character is entered.

thanks

like image 543
Matt Avatar asked Feb 24 '11 02:02

Matt


People also ask

How do I know if EditText has changed?

Implement a TextWatcher. It gives you three methods, beforeTextChanged , onTextChanged , and afterTextChanged . The last method shouldn't be called until something changes anyway, so that's a good thing to use for it.

What does edit text mean?

In android, EditText is a user interface control which is used to allow the user to enter or modify the text. While using EditText control in our android applications, we need to specify the type of data the text field can accept using the inputType attribute.

How do I disable editing in edit text?

To disable an EditText while keeping this properties, just use UI. setReadOnly(myEditText, true) from this library. If you want to replicate this behaviour without the library, check out the source code for this small method.


1 Answers

By using something like this

 meditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {         @Override         public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {             switch (actionId){                 case EditorInfo.IME_ACTION_DONE:                 case EditorInfo.IME_ACTION_NEXT:                 case EditorInfo.IME_ACTION_PREVIOUS:                     yourcalc();                     return true;             }             return false;         }     }); 
like image 58
Reno Avatar answered Oct 12 '22 09:10

Reno