Android disable activity

How can I make the action temporarily insensitive and not customizable?

+2


a source to share


1 answer


You can disable all listeners whenever you want. Another approach I have used is to use a transparent linear layout, or a relative layout that needs to be inflated to cover the entire screen over a period of time.

public void coveredScreen(){
    if(point_total>0){
        parent = (RelativeLayout) findViewById(R.id.main_view); //whatever your layout is
        loadedView = getLayoutInflater().inflate(R.layout.covered_screen, null); //the layout that contains something that fills parent.

        parent.addView(loadedView);

        updateHandler = new Handler();

        updateHandler.postDelayed(coveredScreen, 2000); //opens layout for 2000 ms

        // turns off listeners...
        button1.setClickable(false);
        button2.setClickable(false);

}

Runnable loadingScreen = new Runnable() {
      public void run() {
        // this turns on listeners and removes the inflated view
          parent.removeView(loadedView); 
          button1.setClickable(true);
          button2.setClickable(true);

        // Call this method again every 3 seconds if desired or as long as wanted by uncommenting this handler
        //updateHandler.postDelayed(this, 3000);
      }
    };

      



So ... to set this up while you want it to call every time you want to block any actions from the user within the Activity.

0


a source







All Articles