检测横竖屏:
重写函数:
@Override
public void onConfigurationChanged(Configuration config) {
try {
super.onConfigurationChanged(config);
if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
} else if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
Toast.makeText(TestApp2.this, "哈哈,切竖屏",Toast.LENGTH_SHORT).show();
}
} catch (Exception ex) {
}
}