Flot2011 Flot2011 - 9 days ago 6
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

Next
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
Next
button, but I cannot find any mention of this anywhere.

Answer

Try this code:

yourEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                if (actionId == EditorInfo.IME_ACTION_NEXT)
                    //do what you want
                return false;
            }
        });