我想我已經接近了獲取軟鍵盤IME_ACTION_SEND的監聽者。目標是執行另一個按鈕的點擊。它不顯示在屏幕上的代碼,但在源代碼編輯器中,「OnEditorActionListener()」以紅色下劃線並給出錯誤:軟鍵盤從EditText發送文本到程序
「新的TextView.OnEditorActionListener(){}類型必須實現繼承了抽象方法TextView.OnEditorActionListener.onEditorAction(TextView,int,KeyEvent)「,我以爲是。
「KeyEvent」關鍵字在編輯器中也是一個錯誤:「KeyEvent無法解析爲某種類型」。
可能是我正在做的事情(或不做)。謝謝你的幫助。
et1.setOnEditorActionListener(new OnEditorActionListener() {
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_SEND) {
calculateButton.performClick();
}
return true;
}
});