假设 onCreate
看起来像这样
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
initializeElements();
setOnClickListeners();
updateTable();
}
是否onConfigurationChanged
:
- 必须看起来一样(见下文),
- 我不必使用任何
onCreate
方法或 - 我遗漏了什么?
这是另一种方法。
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
setContentView(R.layout.main);
initializeElements();
setOnClickListeners();
updateTable();
}
最佳答案
如果 onConfigurationChanged 与 onCreate 相同,则不需要 onConfigurationChanged,因为 android 会调用 onCreate。
OnconfigurationChanged 通常在您不希望 android 重新启动您的应用程序时使用,因此您通常只需重新创建 View 并继续运行您的程序。
关于android - 您在 onConfigurationChanged 中使用与 onCreate 中相同的方法吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9232063/