我变得疯狂起来,弄清楚什么是处理屏幕旋转的最佳方法。我在这里阅读了数百个问题/答案,但我真的很困惑。
如何在重新创建活动之前保存myClass数据,以便无需进行其他无用的初始化就可以保留重绘活动的所有内容?
有没有比包裹更清洁,更好的方法?
我需要处理旋转,因为我想在横向模式下更改布局。
public class MtgoLifecounterActivity extends Activity {
MyClass myClass;
// Called when the activity is first created
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
If ( ?? first run...myClass == null ? ) {
myClass = new MyClass();
} else {
// do other stuff but I need myClass istance with all values.
}
// I want that this is called only first time.
// then in case of rotation of screen, i want to restore the other instance of myClass which
// is full of data.
}
青春有我
弑天下
相关分类