java - Lock screen orientation within View class - Android -


i know how within activity class, doesn't fit need. within class extends view, once method called screen orientation locked. , once method called unlocked.

is there way can within class extends view?

thanks.

@override public void onconfigurationchanged(configuration newconfig) {     // todo auto-generated method stub     super.onconfigurationchanged(newconfig);      setcontentview(this.gameview);      if (this.gameview.isorientationchange() == false) {         // stop screen orientation changing during event         switch (this.getresources().getconfiguration().orientation) {             case configuration.orientation_portrait:                 this.setrequestedorientation(activityinfo.screen_orientation_landscape);                 break;             case configuration.orientation_landscape:                 this.setrequestedorientation(activityinfo.screen_orientation_portrait);                 break;         }     }     else {         // allow screen rotations         this.setrequestedorientation(activityinfo.screen_orientation_unspecified);     } } 

in class extending view, there orientationchange boolean field. changed method indicating whether devices orientation can changed. worked screen size changes when orientation changed. if there lot of code dependent on size , timed, may cause more problems solve.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -