当我点击离开时,editText在我的应用程序中不会失去焦点,它始终有橙色边框和黑色线条光标。我根据editText:Stop EditText from gaining focus at Activity startup这样做了一个LinearLayout,这样它就不会关注应用程序的启动。
这是我的代码:
final EditText et = (EditText)findViewById(R.id.EditText01);
final InputMethodManager imm = (InputMethodManager) getSystemService(
INPUT_METHOD_SERVICE);
et.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
imm.showSoftInput(et, InputMethodManager.SHOW_IMPLICIT);
}
});
et.setOnFocusChangeListener(new View.OnFocusChangeListener() {
public void onFocusChange(View v, boolean hasfocus) {
if(hasfocus) {
imm.showSoftInput(et, InputMethodManager.SHOW_IMPLICIT);
} else {
imm.hideSoftInputFromWindow(et.getWindowToken(), 0);
}
}
});但是,当我单击editText之外的任何地方时,它似乎并没有调用onFocusChange!
https://stackoverflow.com/questions/4489439
复制相似问题