我通过Service创建了一个悬浮窗,悬浮窗布局里有EditText,我想让这个EditText只有被点击时才能获取焦点,然后可以弹出输入法,输入完成后,焦点回到这个程序的activity,并且EditText不主动获取焦点
有以下方法
1.通过代码设置:
editText.clearFocus();
2.通过XML属性设置:
<EditText
...
android:focusable="false"
android:focusableInTouchMode="false" />
EditText edit=(EditText)findViewById(R.id.edit);
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(edit.getWindowToken(),0);