private void init() { Button landButton = (Button) findViewById(R.id.landbutton); landButton.setOnClickListener(new ClickListenerlandButton()); Button VButton = (Button) findViewById(R.id.Vbutton); VButton.setOnClickListener(new ClickListenerVButton()); } private class ClickListenerlandButton implements OnClickListener { @Override public void onClick(View v) { landScreen(); } } private void landScreen() { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);//横屏 } private class ClickListenerVButton implements OnClickListener { @Override public void onClick(View v) { VScreen(); } } private void VScreen() { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);//竖屏 }
时间: 2024-11-03 22:18:44