When Dialog is showing, outside edittext in activi

2019-07-21 04:27发布

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

2条回答
太酷不给撩
2楼-- · 2019-07-21 04:37

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

查看更多
我想做一个坏孩纸
3楼-- · 2019-07-21 04:52

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.

查看更多
登录 后发表回答