2010-11-18 4 views

답변

6

귀하의 활동에 android : configChanges = "keyboard | keyboardHidden"을 추가해 보셨습니까?

예컨대 :

<activity android:name=".MyApp" android:label="@string/app_name" android:configChanges="keyboard|keyboardHidden"> 

는 화면상의 키보드뿐만 아니라 실제 하나에 적용되는 경우 확실하지. 또한

당신은 InputMethodManager를 사용하여 온 스크린 키보드와 혼란은, 예를 숨길 당신은 사용할 수 있습니다 :

InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); 
imm.hideSoftInputFromWindow(mCurretnView.getWindowToken(), 0); 
+0

도움 주셔서 감사합니다. 이미 시도했지만 작동하지 않습니다. – Tester

3

으로 this question 사용 :

EditText edtView=(EditText)findViewById(R.id.editTextConvertValue); 
edtView.setInputType(0); 
1
InputMethodManager inputMethodManager = (InputMethodManager) currentActivity.getSystemService(Context.INPUT_METHOD_SERVICE); 
if (isShow) { 
    if (currentActivity.getCurrentFocus() == null) { 
     inputMethodManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); 
    } else { 
     inputMethodManager.showSoftInput(currentActivity.getCurrentFocus(), InputMethodManager.SHOW_FORCED);  
    } 

} else { 
    if (currentActivity.getCurrentFocus() == null) { 
     inputMethodManager.toggleSoftInput(InputMethodManager.HIDE_NOT_ALWAYS, 0); 
    } else { 
     inputMethodManager.hideSoftInputFromInputMethod(currentActivity.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);  
    } 

} 
0

이 시도

@Override 
public boolean dispatchTouchEvent(MotionEvent event) { 
    boolean ret = super.dispatchTouchEvent(event); 
    InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); 
    imm.hideSoftInputFromWindow(mCurretnView.getWindowToken(), 0); 
    return ret; 
} 

또는

editText.setOnTouchListener(new View.OnTouchListener() { 

    @Override 
    public boolean onTouch(View v, MotionEvent event) { 
     InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); 
     imm.hideSoftInputFromWindow(mCurretnView.getWindowToken(), 0); 
     return false; 
    } 
}); 
관련 문제