我是 Android 新手。 我已经花了两个小时在搜索上。无论我尝试什么,软键盘都不会显示在我的 EditText
上。我只是简单地创建了它:
EditText editText = (EditText)findViewById(R.id.editText);
我尝试过:
editText.requestFocus();//i tried without this line too
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
并且:
editText.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus)
{
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
}
});
我也尝试了:
getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE);
我尝试将这行代码放入AndroidManifest.xml
文件中:
android:windowSoftInputMode="stateVisible|adjustResize"
但一切都是徒劳的。它就是从来没有出现过。我缺少了什么?