有人可以给我一个解决方案并解释他/她是如何得出这个特定解决方案的吗?非常感谢
1)当GUI从纵向旋转到横向或相反时,所有局部变量都消失了。写入类的内容,其中标记有To-Do,以便变量isGameFinished通过旋转处理并在应用程序运行时再次收集旋转
班级
public class StatteActivity extends Activity{
private boolean isGameFinished;
private Button buttonFinishGame;
protected void onCreate (Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_state);
//Get previous state for isGameFinished if it exists
//TO-DO
//Find button
buttonFinishGame = (Button) findViewByID(R.id.buttonFinishGame);
buttonFinishGame.setOnClickListener(new OnClickListener(){
public void onClick(View v){
isGameFinished = true;
}
});
if(isGameFinished){
finish();
}
}
protected void onSaveInstanceState(Bundle outState){
//To-Do
super.onSaveInstanceState(outState);
}
}