saveInstanceState works, but updateQuestion make changes?


I’ve run into a small issue after implementing / overriding onSaveInstance state to handle rotations.

When the code is set up like this…

[code] if (savedInstanceState != null) {
mCurrentIndex = savedInstanceState.getInt(KEY_INDEX, 0);


… rotating the screen and transferring the state works beautifully, but then updateQuestion is called and the question is immediately advanced. I tried modifying updateQuestion to disable the incrementing of mCurrentIndex, but then this disables the Next button’s functionality (because clicks to Next call updateQuestion!).

I’m trying to wrap my head around which minor logic step I’m missing – any help would be great!


showNextQuestion() is the method that is supposed to advance to the next question and then update the view by calling updateQuestion(). updateQuestion() only updates the view. I think you have these two methods combined or at least confused.


Right you are! I had the mCurrentIndex increment logic wrapped up in updateQuestion. Separating the two and increasing the index as part of the nextButton’s clickListener did the trick.