Because of how I have my app divided up—a main app file (the main activity) and a library full of all the functions and other
classes—I decided it was important to move all the navigation-drawer-related code (of which there is a fair amount) to a helper class called
This worked marvelously at first. It was all in another class, away and free from infecting my main activity file. Until I turned on the orientation changer. And every time I changed it, it would go blank. Worse yet, when I did so, the button to open and close it stopped functioning also.
I did what any debugger would do and inserted a bajillion print statements into my functions (such as
of the adapter) to see what was going wrong. Somehow,
was returning a value greater than 0, but
was never called.
After two hours (maybe more, I get delusional after a while) of random debugging attempts, I realized that on recreate, Android actually creates a NEW activity—it doesn't call
on the old one. Thus, in the helper class, it was still setting everything for the
Hurr, durr, durr. The moral of the story is: If you're using helper methods, make sure they're using updated data . This has been a public service announcement from Frustrated Java Programmers, Incorporated .