I’m new to android programming and I’m having a little trouble with the following.
I’m trying to make a menu for a game, and I’d like to have an OpenGL view running in the background (with a running demo of the game) and then have the various menu screens change over the top of this; without reloading or affecting the OpenGL view.
At first glance it appears I have a choice of two methods: the first to use separate activities for each screen and then load each individual menu from xml layouts. This obviously reloads a new instance of the OpenGL view per activity. The second option would be to use a single activity and inflate each XML layout on request, leaving the OpenGL view running untouched.
If possible I’d like to use the first method, but as stated all the views end when a new activity is loaded. The second method I think should work – but then I have all the code for the entire menu in a single file. I’m pretty sure I’m missing something.
If anyone can recommend the best approach for this it would be appreciated.
Thanks.
P.S – I guess the desired result is that similar to the Angry Birds menu which has the continually scrolling landscape in the background.
Use Fragments. You can keep one Activity (you’d have to re-initialise openGL for each activity otherwise), and then have different fragments pop up over your openGL stuff.