Question

Let's say that onCreate looks like this

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    initializeElements();
    setOnClickListeners();

    updateTable();
}

Does onConfigurationChanged:

  • has to look the same (see below),
  • I do not have to use any of onCreate methods or
  • I have omitted something?

Here's the other method.

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    setContentView(R.layout.main);  

    initializeElements();
    setOnClickListeners(); 

    updateTable();

}
Était-ce utile?

La solution

If the onConfigurationChanged is the same as onCreate, you shouldn't need to have an onConfigurationChanged because android will call onCreate.

OnconfigurationChanged is normally used when you don't want android to restart your app, so you usually just recreate the view and continue running your program.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top