Flot2011 Flot2011 - 1 year ago 81
Android Question

How to get notification when Next button on Android numeric pad is pressed?

I have a set of custom edit controls, each of them assigns a value to a variable in my app, when losing focus. However when a user presses

on the numeric pad, my control doesn't get a lost focus notification and an associated variable isn't set.

All variables should be set at runtime, exactly when a user changes values, so I cannot just wait till the numeric pad is closed and then update them all.

I also cannot set my variables in control's text change listener, it is a very costly operation, I prefer to do it when a user completes typing.

So my only option seems to be listening on the
button, but I cannot find any mention of this anywhere.

Answer Source

Try this code:

yourEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                if (actionId == EditorInfo.IME_ACTION_NEXT)
                    //do what you want
                return false;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download