edt_search.setOnEditorActionListener( new TextView.OnEditorActionListener() { @Override public boolean onEditorAction( TextView v, int actionId, KeyEvent event ) { //當actionId == XX_SEND 或者 XX_DONE時都觸發 //或者event.getKeyCode == ENTER 且 event.getAction == ACTION_DOWN時也觸發 //注意,這是必定要判斷event != null。由於在某些輸入法上會返回null。 if ( actionId == EditorInfo.IME_ACTION_SEND || actionId == EditorInfo.IME_ACTION_DONE || ( event != null && KeyEvent.KEYCODE_ENTER == event.getKeyCode() && KeyEvent.ACTION_DOWN == event.getAction() ) ) { toNextPage( edt_search.getText().toString() ); return true; } return false; } } );