我创建了一个包含许多活动的Android应用程序,我想让其中一个成为横向:
public class tutorialActivity extends Activity implements SurfaceHolder.Callback, MediaPlayer.OnPreparedListener {
private SurfaceView mSurfaceView;
private MediaPlayer mMediaPlayer;
private SurfaceHolder mSurfaceHolder;
private LinearLayout buttonRegister;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tutorial);
buttonRegister = findViewById(R.id.button_register);
buttonRegister.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// Intent i = new Intent(tutorialActivity.this, MenuActivity.class);
// startActivity(i);
finish();
}
});
mSurfaceView = findViewById(R.id.surfaceView);
mSurfaceHolder = mSurfaceView.getHolder();
mSurfaceHolder.addCallback(tutorialActivity.this);
}
}
并指定到我的清单文件中:
<activity android:name=".activities.tutorialActivity"
android:screenOrientation="landscape"
android:theme="@style/AppTheme.base"></activity>
当我无限制地展示此活动的oncreate活动循环时,请帮我解决这个问题
答案 0 :(得分:1)
清单:
<activity
android:name=".YourActivity"
android:screenOrientation="landscape">
的活动:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);