Android横竖屏切换不重新调用onCreate()

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

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

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

4.0 --> keyboardHidden|orientation|screenSize

 


            
                
                
            

 


 
	@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)
	    { 
	    }
	}

来自:http://www.cnblogs.com/savagemorgan/archive/2013/01/24/2875586.html

你可能感兴趣的:(Android)