soft keyboard sending text from EditText to program
I think I'm close to getting a listener for soft keyboard IME_ACTION_SEND. The goal being for perform click of another button. It doesn't show in the on screen code here, but the "OnEditorActionListener()" is underlined in red in the source editor and gives the error:
"The type new TextView.OnEditorActionListener(){} must implement the inherited abstract method TextView.OnEditorActionListener.onEditorAction(TextView, int, KeyEvent)", I thought I was.
The "KeyEvent" keyword is also an error in the editor: "KeyEvent cannot be resolved to a type".
Probably something dumb i'm doing (or not doing). Thanks for any help.
et1.setOnEditorActionListener(new OnEditorActionListener() {
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.开发者_JS百科IME_ACTION_SEND) {
calculateButton.performClick();
}
return true;
}
});
You need to import the KeyEvent class, that is all :-)
import android.view.KeyEvent;
needed to import:
import android.widget.TextView.OnEditorActionListener;
精彩评论