i need to save the instance of my application when the user rotates the screen.I have used toggle button “inst” , image button “play” and radio button “sp”.This is my code:
public void onSaveInstanceState(Bundle outState)
{
outState.putBoolean("play",play);
outState.putBoolean("inst", inst);
outState.putBoolean("sp",sp); /* shows the error "the method put boolean in
type bundle is not applicable for radio buttons"*/
super.onSaveInstanceState(outState);
}
what are we supposed to use for radio buttons then? When i googled i got results saying that we have to use preference activity.Then in my case, i have to change all the elements in my current layout.Any other solution would be of much help.
you need to put Boolean values only in Bundle.putBoolean method, whereas you are placing RadioButton, ToggleButton in it. SO instead passing View Objects pass state in this method, by getting isChecked property change your code to following: