Disable a whole activity from user action

后端 未结 7 651
再見小時候
再見小時候 2020-12-02 09:17

Is there a simple way to disable a user interacting with an activity. To be done when there is an action running (and a spinning progress bar in the title bar)

EDIT:

7条回答
  •  伪装坚强ぢ
    2020-12-02 09:49

    I have solved this using a custom method - which I did not want to do:

    public static void setViewGroupEnabled(ViewGroup view, boolean enabled)
        {
            int childern = view.getChildCount();
    
            for (int i = 0; i< childern ; i++)
            {
                View child = view.getChildAt(i);
                if (child instanceof ViewGroup)
                {
                    setViewGroupEnabled((ViewGroup) child, enabled);
                }
                child.setEnabled(enabled);
            }
            view.setEnabled(enabled);
        }
    

    If anyone finds a better way I'd like to hear about it! Thanks.

提交回复
热议问题