1.复写
onSaveInstanceState(Bundle outState)
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putInt("key",i);
}
2.在onCreate进行saveInstanceState状态进行判断
protected void onCreate(Bundle savedInstanceState)
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_scroll_view);
if(savedInstanceState!=null){
i = savedInstanceState.getInt("key");
updata(i);
}
}