私のアプリケーションでは、検索ボックスとして機能する編集テキストがあります。 Nexus 7のJelly Beanで、私が聴いているテキストボックスに何かを入力して打鍵すると、KeyEvent = nullが入力され、onIditorAction()メソッドにActionId = 0が渡されます。他に誰かがこれに遭遇しましたか?私はバグかもしれないと思っています。onEditorAction()(Jelly Bean/Nexus 7)のkeyeventとactionid = 0 null
以下の2番目のif文では、actionId = 0およびKeyEvent = nullであるため、NULLポインタが取得されます。
// Search field logic.
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
Log.d(TAG, "onEditorAction");
if (event != null && event.getAction() != KeyEvent.ACTION_DOWN)
return false;
if (actionId == EditorInfo.IME_ACTION_SEARCH
|| event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
.....Do some stuff();
}
}
ではなくedittext' 'の'アンドロイド-edittext'タグを使用してください:) –
'event'は、少なくともハニカムに戻って間違いなく、時には' null'なので、です。ここで私は 'onEditorActionを()'を使用する方法を示すサンプルプロジェクトは、次のとおりです。https://github.com/commonsguy/cw-omnibus/tree/master/ActionBar/ActionBarDemo – CommonsWare
@CommonsWare私はあなたの例を試してみました: –