实现方法也很简单、那就是绑定OnFocusChangeListener事件、实现onFocusChange(View v, boolean hasFocus) 方法、第二个参数就是判断得到焦点或失去焦点、从而实现我得想要的效果、代码如下

 

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 {
			// 此处为失去焦点时的处理内容
		}
	}
});

相关文章:

  • 2021-12-19
  • 2021-12-19
  • 2022-12-23
  • 2022-01-01
  • 2021-12-20
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-15
  • 2022-12-23
  • 2021-12-19
  • 2021-12-19
相关资源
相似解决方案