1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
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"
本文转自 glblong 51CTO博客,原文链接:http://blog.51cto.com/glblong/1217555,如需转载请自行联系原作者