zoukankan      html  css  js  c++  java
  • Android横竖屏切换不重新调用onCreate()

    再次感叹Android的碎片化!!!!

    设置AndroidManifest.xml中Activity的android:configChanges=”keyboardHidden|orientation|screenSize”

    Android4.0需设置screenSize才有效果.

    2.2,2.3这些只需设置keyboardHidden|orientation

    4.0 --> keyboardHidden|orientation|screenSize

    <activity
                android:name=".MainActivity"
                android:configChanges="keyboardHidden|orientation|screenSize"
                android:label="@string/app_name" >
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
    </activity>
    

     
    	@Override
    	public void onConfigurationChanged(Configuration newConfig)
    	{
    		super.onConfigurationChanged(newConfig);
    		
    		if(this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE)
    		{
    			Log.v(TAG, "ORIENTATION_LANDSCAPE");
    		}
    		if(this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT)
    		{
    			Log.v(TAG, "ORIENTATION_PORTRAIT");
    		}
    	    if (newConfig.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO)
    	    { 
    	    } 
    	    else if (newConfig.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_YES)
    	    { 
    	    }
    	}
    
  • 相关阅读:
    MySQL轻量级监测工具—doDBA
    MySQL构建百万级数据
    MySQL备份与恢复—xtrabackup
    MySQL8.0.15二进制包安装
    「考试」省选51
    「总结」二次剩余
    「考试」省选50
    「总结」$pdf$课:$dp2$
    「考试」省选49
    「考试」省选48
  • 原文地址:https://www.cnblogs.com/savagemorgan/p/2875586.html
Copyright © 2011-2022 走看看