Android EditText获取焦点事件

EditText searchView = (EditText) findViewById(R.id.search_text);
searchView.setOnFocusChangeListener(new android.view.View.
		OnFocusChangeListener() {
	@Override
	public void onFocusChange(View v, boolean hasFocus) {
		if (hasFocus) {
			// 此处为得到焦点时的处理内容
		} else {
			// 此处为失去焦点时的处理内容
		}
	}
});

重新获得焦点:

searchView.setFocusable(true);
searchView.setFocusableInTouchMode(true);
searchView.requestFocus();
searchView.clearFocus();//失去焦点
searchView.requestFocus();//获取焦点


你可能感兴趣的:(java,android,boolean,YaphetZhao,Yaphet赵勇)