public class MainActivity extends Activity
{
/**
* 配置xml:横竖屏转换
* android:screenOrientation="portrait" //竖屏
* android:configChanges="keyboardHidden|orientation" //复用,避免销毁activity
*
* 输入法配置:
* android:windowSoftInputMode="adjustPan"
* android:windowSoftInputMode="adjustResize"
*/
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.e("onCreate", "onCreate");
}
@Override
protected void onDestroy()
{
super.onDestroy();
Log.e("onDestroy", "onDestroy");
}
@Override//换屏保存的方法
protected void onSaveInstanceState(Bundle outState)
{
super.onSaveInstanceState(outState);
Log.e("onSaveInstanceState", "onSaveInstanceState");
}
@Override//换屏保存的方法
protected void onRestoreInstanceState(Bundle savedInstanceState)
{
super.onRestoreInstanceState(savedInstanceState);
Log.e("onRestoreInstanceState", "onRestoreInstanceState");
}
@Override//监测屏幕转换
public void onConfigurationChanged(Configuration newConfig)
{
super.onConfigurationChanged(newConfig);
Log.e("onConfigurationChanged", "onConfigurationChanged:"+newConfig.orientation);
}
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
其他:
1.如果是popwindow中的输入框,要如下设置才有效
"android:windowSoftInputMode="stateVisible|adjustResize|stateAlwaysHidden"
转载于:https://blog.51cto.com/glblong/1217555