//把虚拟键盘的回车改成搜索
searchEditText.setImeOptions(EditorInfo.IME_ACTION_SEND);
searchEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
// TODO Auto-generated method stub
if (actionId==EditorInfo.IME_ACTION_SEND ||(event!=null&&event.getKeyCode()== KeyEvent.KEYCODE_ENTER))
{
//do something;
dealWithSearch();
return true;
}
return false;
}
});
dealWithSearch()方法是点击搜索触发的事件实现内容。