1 Edittext焦点变化监听
editSearch.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
} else {
}
}
});
2 activity 收起软件盘
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_search_question);
ButterKnife.bind(this);
imm = (InputMethodManager) editSearch.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
}
public void hideInputWindow(Activity context) {
if (context == null) {
return;
}
final View v = getWindow().peekDecorView();
if (v != null && v.getWindowToken() != null) {
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
}
editSearch.clearFocus();//清除edittext焦点
}