вызовите виртуальный метод 'int android.view.KeyEvent.getAction ()' для нулевого объекта referenceid.view.KeyEvnt.getAction () - PullRequest
0 голосов
/ 21 сентября 2019

У меня есть этот код:

public ClearableEditText(Context context, AttributeSet attrs) {
    super(context, attrs);

    setOnEditorActionListener((v, actionId, event) -> {
        if (event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
            return true;

        }
        return false;
    });

И возвращает эту ошибку

в widget.ClearableEditText $ 1.onEditorAction (ClearableEditText.java:34)

Как я могу справиться с этим?

1 Ответ

0 голосов
/ 21 сентября 2019

Используйте actionID вместо action_event.Надеюсь, это будет решено.Пример кода ниже: -

your_edittextfield.setOnEditorActionListener(new TextView.OnEditorActionListener() {
    @Override public boolean onEditorAction(TextView edt, int actionId, KeyEvent key) {
        boolean handled=false;
        if(actionId==EditorInfo.IME_ACTION_DONE) {
            //Do your task here
            handled=true;
        }
        return handled;
    }
});
...