設置我有一個Android應用程序,在它的一個組成部分的鍵盤工作正常,除了那 - 雖然用下面的代碼打開 - 沒有出現:Android不顯示鍵盤雖然在代碼
View.OnFocusChangeListener vof = new View.OnFocusChangeListener() {
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
}
}
};
// ...
final TextView input = (TextView) findViewById(R.id.answer);
input.setOnFocusChangeListener(vof);
input.requestFocus();
我在其他幫助頁面上可以找到的所有東西都只有這個解決方案,當我嘗試在我的Samsung Galaxy S2上使用它時,這種解決方案無效。
你確定onFocusChange被調用嗎? – njzk2 2011-12-19 17:49:24
@ njzk2我確定它是 - android的sdk/adt for eclipse自動添加了這個方法,我不認爲這是錯誤的。此外,此代碼適用於此應用中的另一個textedit。 – hlt 2011-12-19 18:35:12
我現在找到了解決方案...查看我的編輯 – hlt 2011-12-19 19:19:04