旋转与点击活动在Button [英] Rotate the Activity with click on a Button

查看:174
本文介绍了旋转与点击活动在Button的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用这code禁用自动在我的应用程序旋转:

 的android:screenOrientation =画像

我要的是通过点击按钮来写一个code我的活动内,以在纵向景观的应用程序为用户想要并保存在共享preferences。

我已经做的布局布局土地有不同的设计,但正如我在体现其没有显示出来,禁用它,因为我希望用户选择了什么他们要!

感谢您的任何帮助

更新

  / **这里是旋转按钮* /
View.OnClickListener MB2 =新View.OnClickListener(){
    公共无效的onClick(视图v){
        startActivity(新意图()关于);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);    }
};

它不以这种方式工作!


解决方案

  setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

  setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

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!

解决方案

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

or

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

这篇关于旋转与点击活动在Button的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆