I need some help in Android
Can someone kindly give me a solution to this and explain how he/she came
to that particular solution? Thanks so much
1) Upon rotation of the GUI from portrait to landscape or the opposite
disappears all local variables.Skriv content of the class, where it is
marked with To-Do, so that variable isGameFinished taken care of by
rotation and collected again when the app is rotated
Class
public class StatteActivity extends Activity{
private boolean isGameFinished;
private Button buttonFinishedGame;
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);
}
}
No comments:
Post a Comment