Question

I wrote a sample application for the NavigationDrawer pattern with the ActionBar-Compat library project. Every time i change from portrait to landscape mode i got a NullPointerException during onAttach(). The Activity returns null for the getSupportActionBar() method. This happens in the Fragment which is changed by the NavigationDrawer. You can find the code on my github project: FadingActionBar-Compat (Line 162)

Maybe it is a error which can be fixed by a update from google in the future?

Was it helpful?

Solution

I found the solution by looking in to the ActionBar Compat source code. The ActionBar is ready to use in the lifecycle methode onActivityCreated(). You musst call the super-Method before. After that you can call getSupportActionBar() without a NullPointerException.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top