OnEditorActionListener code

2019-08-16 05:34发布

I'm trying to get this code working. It has been posted as a solution to detecting the "done" or "next" button on a softkeyboard but I get the error "must implement inherited abstract method..onEditorAction.."

import android.widget.TextView.OnEditorActionListener;

textEdit5.setOnEditorActionListener(new OnEditorActionListener() {

public boolean onEditorAction(TextView arg0, int keycode, KeyEvent event) {

    if(arg1 == KeyEvent.FLAG_EDITOR_ACTION){
             btnSave.requestFocus();
            return true;
    }

    return false;

    });

1条回答
看我几分像从前
2楼-- · 2019-08-16 06:30

You have to @Override the method for proper execution.

textEdit5.setOnEditorActionListener(new OnEditorActionListener() {

    @Override
    public boolean onEditorAction(TextView arg0, int keycode, KeyEvent event) {
            if(arg1 == KeyEvent.FLAG_EDITOR_ACTION){
            btnSave.requestFocus();
            return true;
 }
return false;

});

This should work.

查看更多
登录 后发表回答