Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Android中显示方向改变时的活动?_Android - Fatal编程技术网

如何在Android中显示方向改变时的活动?

如何在Android中显示方向改变时的活动?,android,Android,当我将设备从纵向转到横向时,我的活动将重新启动。对于该活动,我需要同时使用纵向和横向模式 如何显示我的活动?在清单文件中添加这一行android:configChanges=“orientation | keyboardHidden” <activity android:name=".imgview" android:configChanges="orientation|keyboardHidden" andro

当我将设备从纵向转到横向时,我的活动将重新启动。对于该活动,我需要同时使用纵向和横向模式


如何显示我的
活动?

在清单文件中添加这一行
android:configChanges=“orientation | keyboardHidden”

<activity android:name=".imgview"
                  android:configChanges="orientation|keyboardHidden"   
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

要避免重新启动,请在
AndroidManifest
中为您的
活动使用
android:configChanges=“keyboardHidden | orientation”

  public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        Log.e("ScreenMode",""+screenMode); 
        if(screenMode==1)
        {Log.e("ScreenMode",""+screenMode);
            buildUrl(result,startPage);
            showImageList();
        }

        if(screenMode==2)
        {
            showOneImage(forFunc);
        }
        if(screenMode==0)
        {
            startOMG();
        }
    }