Disable a whole activity from user action

后端 未结 7 660
再見小時候
再見小時候 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:56

    The code of Uriel Frankel (accepted response), works good, but in my case works after my request it's done :(. I want to block before it happend. Some one knows what is wrong in my code (I'm beginning in this..)

    (this is a fragment)

       login_login_btn.setOnClickListener {
    
        if (validateInputs()){
            showSpinner()
            thread {
                doLogin()
            }
        } else {
            validationError("Validation Error","Checkout your inputs. Common errors: \npassword (at least 8 characters)")
        }
    
    }
    

    }

    Function after OnViewCreated

    fun showSpinner(){
        activity?.window?.setFlags(
            WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE,
            WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE)
        spinner.visibility = View.VISIBLE
    }
    

    Thank you (Y)

提交回复
热议问题