当我在模拟器中切换方向( ctrl+F11 )时,为什么不调用onConfigurationChanged重写方法。
public class HelloSample extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
setContentView(R.layout.main);
System.out.println("Change in Orientation");
}
}在manifest.xml中
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".HelloSample"
android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>发布于 2011-10-19 09:42:22
使用真实的设备,模拟器不支持。
https://stackoverflow.com/questions/7815578
复制相似问题