|
@Override
public void onConfigurationChanged(Configuration newConfig) {
// TODO Auto-generated method stub
super.onConfigurationChanged(newConfig);
if(newConfig.orientation==ActivityInfo.SCREEN_ORIENTATION_PORTRAIT)
{
Toast.makeText(this,"现在是竖屏", Toast.LENGTH_SHORT).show();
container.removeAllViews();
container.addView(getLocalActivityManager().startActivity(
"Module2",
new Intent(zhujiem.this, BeateryActivity.class)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
.getDecorView());
}
else if(newConfig.orientation==ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE)
{
container.removeAllViews();
container.addView(getLocalActivityManager().startActivity(
"Module1",
new Intent(zhujiem.this, hengping.class)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
.getDecorView());
Toast.makeText(this,"现在是横屏", Toast.LENGTH_SHORT).show();
}
}
AndroidManifest.xml中的配置
<activity android:name=".zhujiem"
android:configChanges="keyboardHidden|orientation"
android:label="@string/app_name">
<intent-filter>
</activity>
请教这样写应该没错把,但是怎么就不响应横屏事件?为啥? |
|