Code doesn't work


#1

Hello everyone, so, I’ve checked every line of code at least 10 times and have spent hours thinking about this problem. My code would just go back to the first question when orientation is changed. If you can, please help me resolve my problem.
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.d(TAG, "OnCreate(Bundle) called"); setContentView(R.layout.activity_main); if (savedInstanceState != null) { mCurrentIndex = savedInstanceState.getInt(KEY_INDEX, 0); }

@Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); Log.i(TAG, "onSavedInstance() called"); outState.putInt(KEY_INDEX, mCurrentIndex); }