问题
I am using this CODE to disable the auto rotate in my App:
android:screenOrientation="portrait"
What I want is to write a CODE inside my Activity to make the App on portrait or landscape as the user want by clicking a button and save it in SharedPreferences.
I am already made layout and layout-land with different design but as i disabled it in my Manifest its is not showing up, Cause i want the users chose what they want!
Thanks for any Help
UPDATE
/** Here is the Rotation Button */
View.OnClickListener mb2 = new View.OnClickListener() {
public void onClick(View v) {
startActivity(new Intent(".ABOUT"));
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
};
It doesn't work this way!
回答1:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
or
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
来源:https://stackoverflow.com/questions/21363021/rotate-the-activity-with-click-on-a-button