SoftKeyboard 不会在横向模式下自动出现

SoftKeyboard not Appearing automatically in Landscape Mode

我在 XML 中有 EditText<requestFocus />。当我在纵向模式下打开Activity时,软键盘自动出现,但是当我在横向模式下启动activity时模式软键盘不会自动出现。我需要触摸软键盘的 EditText

想要软键盘在横向模式下自动出现。

Android 清单

<activity
            android:name="activity"
            android:windowSoftInputMode="adjustResize"
           >

有什么问题请帮帮我

InputMethodManager imm = (InputMethodManager)this.getSystemService(Service.INPUT_METHOD_SERVICE);

为了显示键盘,请在以下 if 条件下使用它,我希望它会起作用

imm.showSoftInput(ed, 0);

您可以通过以下方式完成此操作:

横向

if(getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE){
    //Do some stuff
}

肖像

if(getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT){
    //Do some stuff
}

编辑:尝试使用此代码

editText1 = (EditText) findViewById(R.id.editText1);

InputMethodManager input = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
input.showSoftInput(editText1, RESULT_UNCHANGED_SHOWN);
setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE | LayoutParams.SOFT_INPUT_ADJUST_PAN )

请检查一下,我已经测试了这个解决方案,它运行良好

@Override
    protected void onResume() {
        super.onResume();
        mUserNameEdit.requestFocus();

        mUserNameEdit.postDelayed(new Runnable() {

            @Override
            public void run() {
                // TODO Auto-generated method stub
                InputMethodManager keyboard = (InputMethodManager)
                getSystemService(Context.INPUT_METHOD_SERVICE);
                keyboard.showSoftInput(mUserNameEdit, 0);
            }
        },200);
    }