2014-10-07 4 views
0

나는 다양한 EditText 및 확인 버튼이있는 양식을 가지고 있습니다. 사용자가 EditText이 무엇이든지 확인을 클릭하면 키보드가 잠시 닫히고, 사용자가 EditText 중 하나를 다시 편집하려고하면 키보드가 다시 나타납니다.현재 EditText가 현재 활성화되어있는 모든 키보드를 일시적으로 닫는 방법

EditText을 개별적으로 제어하기 위해 많은 수의 코드 라인을 추가하지 않으면 어떻게 될까요?

답변

1

사용 단순히 InputMethodManager

이 방법

InputMethodManager imm = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE); 
imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0); 
+0

딱! 5 분 카운트 다운 후에 답을 수락합니다. 감사. – AndreaF

+0

귀하의 환영;) –

0
InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE); 
       //Find the currently focused view, so we can grab the correct window token from it. 
View view = getCurrentFocus(); 
//If no view currently has focus, create a new one, just so we can grab a window token from it 
if(view == null) { 
    view = new View(this); 
} 
inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0); 

키보드가 동일한 편집 텍스트에 대해 게인을 열 것인지, 시도하지 않았는지 확실하지 않지만이 작업은 keybord를 닫습니다.

관련 문제