在對應的Activity註冊的時候添加
android:configChanges="orientation|keyboardHidden|screenSize"
就行了。
還可以在這個Activity中添加如下代碼對屏幕旋轉進行監聽:
@Override
public void onConfigurationChanged(Configuration newConfig) {
// TODO Auto-generated method stub
super.onConfigurationChanged(newConfig);
if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
// 監聽橫屏
} else if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
// 監聽豎屏
}
}