APP 旋转前保存数据

创建水平布局之后,

在QuizActivity 中添加 private static final String KEY_INDEX = “index”;


@override
public void onSaveInstanceState(Bundle savedInstanceState){
    super.onSaveInstanceState(savedInstanceState);
    Log.i(TAG,"onSaveInstanceState");
    savedInstanceState.putInt(KEY_INDEX,questionNumber);
}
 
  

if(savedInstanceState!=null)
{
    questionNumber = savedInstanceState.getInt(KEY_INDEX,0);
}
updateQusetion();

}

你可能感兴趣的:(安卓)