0
我有這個OnFocusChangeListener
:如何保持鍵盤上的焦點變化開放,但不關閉並重新打開
View.OnFocusChangeListener onFocusChangeListener = new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
InputMethodManager myIMM = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
if(hasFocus) {
myIMM.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, 0);
} else {
myIMM.hideSoftInputFromWindow(v.getWindowToken(), 0);
}
}
};
我這個監聽器設置爲每EditText上我做編程。有效,但有時不。它給出了很多這樣的警告:
W/IInputConnectionWrapper: getTextBeforeCursor on inactive InputConnection
W/IInputConnectionWrapper: getTextBeforeCursor on inactive InputConnection
W/IInputConnectionWrapper: getTextBeforeCursor on inactive InputConnection
W/IInputConnectionWrapper: getTextBeforeCursor on inactive InputConnection
W/IInputConnectionWrapper: getTextBeforeCursor on inactive InputConnection
W/IInputConnectionWrapper: getTextBeforeCursor on inactive InputConnection
有時我可以看到鍵盤關閉並重新打開。 所以,我認爲這個問題是因爲我打開和關閉鍵盤很多次。我怎樣才能保存鍵盤狀態?所以,如果新焦點是EditText,鍵盤不會關閉。
對不起,英文不好,我希望你能理解。
是的,但我想那鍵盤收盤失去焦點。 –