2010-11-18 3 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; 
    } 
}); 
Смежные вопросы