• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Easy menu question

louched1

Lurker
Hi all,

I'm new to android development and I want to create a menu for my app. The problem is that when I search for instructions, they all want to talk about what to do when the user presses the menu button which is not what I'm looking for.

Here's a pic to show what I'm trying to do. The user would load my app and be presented with something pretty much identical to this.

Menu.jpg

I have one of the three parts coded and working just fine, but in the end I want the user to choose between the three options instead of stacking the three parts vertically on one screen.

How can I accomplish this? Or where can I go to find this info?

Thanks!
 
Thanks jiminaus, but that's not what I'm looking for. The code solution posted for them is a step behind where I'm at. I can create that menu. I'm trying to make that menu switch to a new screen when one of the buttons is pushed.

I can create a menu in the main.xml file. I can make onClick methods that tell those buttons to do stuff. What I'm looking for is how android handles a screen switch once a menu option has been selected. I'm currently stuck with one screen for the user (main.xml) and I don't want to stack everything on one screen.

Does this involve multiple xml files? Where does these xml files go? How do I reference it them to make the switch between screens? Does each new screen need it's own class? Things like that.

I'm certain there's documentation on this somewhere as it's an extremely basic. I'm just having troubles finding said documentation because of the overlapping terminology. Searching for menu tutorials brings up how to handle the user pressing the menu button. Searching for multiple screens brings up how to support different phone screen sizes.

Maybe the picture below will clear up what I'm trying to do?

MainMenu.jpg
 
so you just want to start a new activity when the user presses one of the buttons?

In that case, when the user presses a button, you can start a new activity like so:

Code:
startActivity(new Intent(NameOfStartActivity.this, NameOfNewActivity.class);

To dertermine exactly which activity to launch, just use a switch statement (or series of conditionals depending on your onClick implementation).
 
"new activity" is the phrase I was looking for! Thanks, I can take it from here. :)

EDIT: And it's working. :D Thanks much!
 
Back
Top Bottom