When Dialog is showing, outside edittext in activity not showing the soft keyboard in android

泄露秘密 提交于 2019-12-11 04:07:52

问题


now i had a severe problem. I am having one activity and in that i have one edit text. I want to show up a customized dialog box on the top right of that activity. Now what my problem is while the dialogue is showing, when i click the edit text, soft keyboard is not showing....please help i want to show the keyboard while the dialog is showing... i have searched many..i found solution for the edit text inside the dialog but i need for the edit text which is outside the dialog...please help


回答1:


Hi finally i got answer for my question.

objDialogueWindow = objDialogue.getWindow();
objDialog.setOnShowListener(new OnShowListener() {

                @Override
                public void onShow(DialogInterface dialog) {
                    // TODO Auto-generated method stub
                    objDialogWindow.setFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
                    objDialogWindow.setFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM, WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
                }
            });

This will solve my problem. Window flag: invert the state of FLAG_NOT_FOCUSABLE with respect to how this window interacts with the current method. That is, if FLAG_NOT_FOCUSABLE is set and this flag is set, then the window will behave as if it needs to interact with the input method and thus be placed behind/away from it; if FLAG_NOT_FOCUSABLE is not set and this flag is set, then the window will behave as if it doesn't need to interact with the input method and can be placed to use more space and cover the input method. Please refer the explanation in http://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#FLAG_ALT_FOCUSABLE_IM




回答2:


When you open a dialog from the activity which has edittext, softkeyboard will automatically hide as on moving to dialog edittext looses the focus. Showing softkeyboard along with dialog won't be possible, you need to add the content of your dialog in the activity itself where edittext is there. And you can play with the visibility of the view containing dialog contents whenever you want your dialog to appear and disappear.



来源:https://stackoverflow.com/questions/27458677/when-dialog-is-showing-outside-edittext-in-activity-not-showing-the-soft-keyboa

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!