Tôi đang sử dụng . Trong đó, khi tôi đang thay đổi từ LandScape thành Portrait, nó đang gọi if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT)
và chuyển sang Portrait từ LandScape. Nhưng khi tôi thay đổi từ Portrait thành Land-Scape, nó không thay đổi thành LandScape vì nó đang gọi if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE)
vì vậy, nó không thay đổi từ LandScape thành Portrait. Xin vui lòng giúp đỡ.Cách sử dụng onConfigurationChanged() và newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE trong android 2.3.3
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
//int orientation = this.getResources().getConfiguration().orientation;
if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
Log.d("Entered to change as Portrait ","PPPPPPPPPPPPPPPPP");
setContentView(R.layout.settings);
} else if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
Log.d("Entered to change as LandScape ","LLLLLLLLLLLLLLLLLLLL");
setContentView(R.layout.settings);
}
}
Nếu bạn trên máy tính bảng cũng thêm '| screenSize' để android: configChanges –