ADDING A HELP MENU TO YOUR B4A PROJECT · 2014. 8. 1. · ADDING A HELP MENU TO YOUR B4A PROJECT...
Transcript of ADDING A HELP MENU TO YOUR B4A PROJECT · 2014. 8. 1. · ADDING A HELP MENU TO YOUR B4A PROJECT...
ADDING A HELP MENU TO YOUR B4A PROJECT
After a great effort by others to give me enough knowledge to add a help menu to my project I thought it
best if I make a few notes before I forget. This is it.
This method uses Webview to display a HTML file. This is not the only method but I found this works so
this is what I will continue to use.
The following notes use the myfirstprogram example from the Beginners Guide.
STEP 1: THE HTML FILE.
If you know how to create a HTML file, use what you know. If you are unfamiliar with HTML, one simple
method is to write your help file in Word and “Save As” (Web Page htm, html).
Save your word file as “helpfile.html” to the files directory of your project.
NOTE: Use all lower case letters for the file name.
STEP 2: ADD THE HTML FILE TO THE PROJECT.
Although the “helpfile.html” file is sitting in the project files directory it is still not part of the project. To
achieve this, in the main screen of the IDE select the “Files” tab, add files, open “helpfile.html”.
“helpfile.html” will then appear in the right hand panel of the IDE.
1. Select Files Tab
2.Select Add Files
3.Select helpfile.html
STEP 3: CREATE A NEW ACTIVITY.
In the main IDE screen select Project > Add New Module > Activity Module
Name the acitivity HelpActiv and you should see the new activity in the IDE.
STEP 4: CREATE A NEW LAYOUT.
In the HelpActiv activity of the IDE start the designer and select File > New.
Save the layout, in the designer File > Save. Save using the name HelpLay.
File > Save
STEP 5: ADD A WEBVIEW.
In the HelpActiv activity > designer and add a WebView.
Name the Webview “HelpView” and set the parameters as shown.
STEP 6: GENERATE MEMBERS.
In the designer select Tools > Generate Members, select HelpView and click the Generate Members button.
Close that screen and check HelpActiv.
STEP 7: ADD CODE.
In the main screen of the IDE select the “Main” activity and the end of the code area add the following SUB
Sub HelpSub_Click
StartActivity(HelpActiv)
End Sub
… and the AddMenuItem to the FirstTime Sub
Sub Activity_Create(FirstTime As Boolean)
...
Activity.AddMenuItem("Help", "HelpSub")
...
End Sub
Then select the HelpActiv activity in the main IDE screen and add the code to the FirstTime Sub
Activity.LoadLayout("HelpLay")
HelpView.LoadURL("file:///android_asset/helpfile.html")
STEP 8: TEST.
Test that all is well, start the AVD [or real device].
Set the IDE to “Release”, the HTML won’t be found if you are in debug mode. ???
Run the program, - click Menu > Help
If all is well Then
you will see your Help File displayed
Else
post a question on the forum.