简体   繁体   English

如何使弹出窗口模态化

[英]How to make a popup window modal

I have a popup window that shows during initial app launch.我有一个在初始应用程序启动期间显示的弹出窗口。 Here is the code, I used to create the Popup window这是代码,我用来创建弹出窗口

private void loadPopup(View view, boolean loadSchool){
        Log.i("Started Info","popup");

        //.......

        //create the popup window
        int width = LinearLayout.LayoutParams.WRAP_CONTENT;
        int height = LinearLayout.LayoutParams.WRAP_CONTENT;
        boolean focusable = true;
        popupWindow = new PopupWindow(layout, width, height, focusable);

        //Show the popup window
        popupWindow.showAtLocation(view, Gravity.CENTER, 0, 0);
    }

This works fine and shows the popup properly.这工作正常并正确显示弹出窗口。 However, if I touch (click) outside the Popup window it gets dismissed.但是,如果我在弹出窗口外触摸(单击)它会被关闭。 So how can I make this Popup window modal, so that a user have to respond to it before s/he can get back to the other activity?那么我怎样才能使这个弹出窗口模态化,以便用户必须在他/她回到其他活动之前对其做出响应?

You can try add the proprety.您可以尝试添加属性。

popupWindow.setOutsideTouchable(false);
popupWindow.setFocusable(true);

尝试方法PopupWindow.setTouchModal()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM