OnEditorActionListener code

感情迁移 提交于 2019-12-13 06:27:51

问题


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:


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.



来源:https://stackoverflow.com/questions/16932899/oneditoractionlistener-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!