问题
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