et_key.setOnEditorActionListener(newTextView.OnEditorActionListener() {
@Override
public booleanonEditorAction(TextView v, intactionId,KeyEvent event) {
if(actionId == EditorInfo.IME_ACTION_SEARCH){
// 先隐藏键盘
((InputMethodManager)et_key.getContext().getSystemService(Context.INPUT_METHOD_SERVICE))
.hideSoftInputFromWindow(
SearchActivity.this
.getCurrentFocus()
.getWindowToken(),
InputMethodManager.HIDE_NOT_ALWAYS);
String keyWord =et_key.getText().toString().trim();
searchByKeyWord(keyWord);
return true;
}
return false;
}
});