Menu

wheretheidivides

Active Member
Licensed User
Longtime User
OK, after spending 2 days looking for this on the forem, I'll just ask. The info I see doesn't really help much.


I want to use the hardware menu key. The menu key would display a help screen (or several help screens) (or 1 long scrolling menu with the instructions). The options in the menu would then show a full screen panel with instructions. Sense the layout would be different, I would use a diferent module. So module 2 would have several different panels I could make visible to show the instructions pages.

That's it. Nothing fancy.

Could someone post example code of this? i could just modify the code. I found this to be a lot easier.


"Remember, the B in BASIC stands for Beginners"
 

klaus

Expert
Licensed User
Longtime User
Attached a small example that will let you begin with.
Instead of having the panels in the activity you can also create one layout file for each panel and add the panels by code and load their respective layout files.

Best regards.
 

Attachments

  • MenuPanels.zip
    5.9 KB · Views: 565
Upvote 0

wheretheidivides

Active Member
Licensed User
Longtime User
Would doing it this way mess up the layout already in the module main? I am just trying to have a menu pop up after pressing the menu button.

'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.

End Sub

Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim Panel0, Panel1, Panel2, Panel3 As Panel
End Sub

Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("MenuPanels")
Activity.AddMenuItem("Help1","Help")
Activity.AddMenuItem("Help2","Help")
Activity.AddMenuItem("Help3","Help")
Panel1.Top = 0
Panel1.Left = 0
Panel2.Top = 0
Panel2.Left = 0
Panel3.Top = 0
Panel3.Left = 0
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub Help_Click
Select Sender
Case "Help1"
Panel1.Visible=True
Case "Help2"
Panel2.Visible=True
Case "Help3"
Panel3.Visible=True
End Select
End Sub

Sub Button_Click
Dim Send As Button

Send = Sender

Select Send.Tag
Case "1"
Panel1.Visible=False
Case "2"
Panel2.Visible=False
Case "3"
Panel3.Visible=False
End Select
End Sub
 
Last edited:
Upvote 0

SarahWard

Banned
Attached a small example that will let you begin with.
Instead of having the panels in the activity you can also create one layout file for each panel and add the panels by code and load their respective layout files.

Best regards.

Klaus

I don't understand how I would use your program to give the 3 help buttons names like: Options, Settings, etc.

If you change the TITLE 'help1' and 'help2' value the help buttons don't work. For instance...

Your code works...

Activity.AddMenuItem("Help1","Help")
Activity.AddMenuItem("Help2","Help")


Changing the titles of each help button doesn't work...

Activity.AddMenuItem("OPTIONS","Help")
Activity.AddMenuItem("SETTINGS","Help")
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Hi Sarah,

When you change the Title of a menu item you must use this same name in the event routine. In our exapmle:
Changing:
B4X:
Activity.AddMenuItem("Options","Help")
Activity.AddMenuItem("Settings","Help")
Activity.AddMenuItem("Help3","Help")
You must also change this:
B4X:
Sub Help_Click
    Select Sender
    Case "Options"
        Panel1.Visible=True
    Case "Settings"
        Panel2.Visible=True
    Case "Help3"
        Panel3.Visible=True
    End Select
End Sub
Best regards.
 
Last edited:
Upvote 0

Mikie

Member
Licensed User
Longtime User
I am a newbie. Attaching a simple menu app. Keep in mind I am not in Klaus's league.
 

Attachments

  • BasicMenu1c.zip
    10.8 KB · Views: 375
Upvote 0

JaunLukePicard

Member
Licensed User
Longtime User
Klaus,

This menu example is close to what I am looking for. Is it possible to use a layout file just for the menu I want as opposed to using AddMenuItem? Or are Layout files used soley for full screens on the device?

If a Layout file cannot be used can we use a Panel and add buttons to that panel and achieve the same effect?

I like the menu feature, but prefer to use the Button view as I can size and color the button as I like.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
No you can't use a layout file for the menu.
You could have a look at chapter 12.1 Example programs / User interfaces page 144 in the Beginner's Guide.
There are three examples: Menu, TabHost and Buttons.
I have been a Button fan for a long time already in Windows programs.

Best regards.
 
Upvote 0
Top