OnEditorActionListener代码

时间:2013-06-05 06:23:37

标签: android android-edittext textview

我正在努力让这段代码正常运行。它被发布作为检测软键盘上的“完成”或“下一步”按钮的解决方案,但我得到错误“必须实现继承的抽象方法..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 个答案:

答案 0 :(得分:1)

您必须@Override方法才能正确执行。

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;

});

这应该有用。