So I have this Java code:
editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE) {
doSomething();
return true;
}
return false;
}
});
我设法做到了这一点(我甚至不确定这是不是正确的方式):
editText.setOnEditorActionListener() { v, actionId, event ->
if(actionId == EditorInfo.IME_ACTION_DONE){
doSomething()
} else {
}
}
But I get an error Error:(26, 8) Type mismatch: inferred type is kotlin.Unit but kotlin.Boolean was expected
那么这样的事件处理程序是如何用Kotlin 编写的呢?