【问题标题】:onConfigurationChanged is not called未调用 onConfigurationChanged
【发布时间】:2011-10-19 09:42:21
【问题描述】:

为什么我在模拟器中切换方向( 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>

【问题讨论】:

    标签: android


    【解决方案1】:

    使用真机,模拟器不支持。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-09-21
      • 2013-05-18
      • 1970-01-01
      • 2013-07-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-02
      相关资源
      最近更新 更多