ThemePark wrote: > The idea is to change the views, whenever I press one of the radio > buttons. When I press a button the first time everything works out > fine, but the second time I press a button, I get an > IllegalStateException, and I can't quite see why I'm getting this.
The full Java stack trace, from adb logcat, DDMS, or the DDMS perspective in Eclipse, may give you more clues. > Also, the Activity seems to set all my global variables to null, which > is why I have to create them every time I switch from portrait to > landscape or vice versa. Java does not have global variables. > So I would like to know if there is a way I > can save my views in the Bundle, or any other way in which I can > permanently save my views, so I don't have to add or create them every > time, I flip the phone. No. Doing so would cause crashes at best and memory leaks at worst. If you do not want your activity destroyed when the orientation changes, you can set up a manifest entry for that: http://www.androidguys.com/2008/11/11/rotational-forces-part-three/ > And whenever I flip the phone, it seems that > it rereads the main XML file, causing the RadioGroup to be set to 2D > even if the 3D button is checked. Correct. Your activity is being destroyed and recreated. > This is because I've said the 2D > button to be checked from when the app is first created, but I would > like to also save the state of that RadioGroup. Assuming you do not go down the path I pointed you to above, you can save the state of your RadioButton in onSaveInstanceState() and re-apply it in either onCreate() or onRestoreInstanceState(). -- Mark Murphy (a Commons Guy) http://commonsware.com | http://twitter.com/commonsguy Android 2.0 Programming Books: http://commonsware.com/books -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en