@Override
protected Parcelable onSaveInstanceState() {
// TODO Auto-generated method stub
Bundle bundle = new Bundle();
bundle.putParcelable(Instance, super.onSaveInstanceState());
bundle.putBoolean(Instance_GameOver, IsGameOver);
bundle.putParcelableArrayList(Instance_WhiteArray, whiteArray);
bundle.putParcelableArrayList(Instance_BlackArray, blackArray);
return bundle;
}
@Override
protected void onRestoreInstanceState(Parcelable state) {
// TODO Auto-generated method stub
if(state instanceof Bundle)
{
Bundle bundle=(Bundle) state;
IsGameOver=bundle.getBoolean(Instance_GameOver);
whiteArray=bundle.getParcelableArrayList(Instance_WhiteArray);
blackArray=bundle.getParcelableArrayList(Instance_BlackArray);
super.onRestoreInstanceState(bundle.getParcelable(Instance));
return ;
}
super.onRestoreInstanceState(state);
}
在打电话或者翻转屏幕可能会清空view,调用这两个方法,只需要改动里面内容即可恢复与保存。