android 把虚拟键盘的回车改为搜索功能(亲试)

 //把虚拟键盘的回车改成搜索
        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()方法是点击搜索触发的事件实现内容。

你可能感兴趣的:(android,隐藏虚拟键盘,回车变搜索)