B4A Library [Class] HelpReader

This is a class based upon Klaus' scrollview example help reader. I have made several changes and additions, but it is basically the same function.

It requires the StringUtils library


HelpReader expects to find help files based on the path you send to the Initialization method. Each file is named help folowed by a number and ending with .txt like this:

help0.txt
help9.txt

The entire filename must be in lower case. The reader starts at 0 and counts the number of help files when it is first initialized. Each file is considered a help page, and they are text only.

The first 2 lines of each file are the page heading and the topic heading, the rest of the file is the body text. These 2 headings can be any color you wish. The page heading will be centered and may word wrap. The topic heading is left justified and may also wrap.

If you don't wish to use a page or topic heading, then use 2 empty lines at the beginning of each file. If you use page headers, but don't care about topics, then leave a blank line under the page heading line in your file(s). The class will adjust as it goes along.

You can choose weather to have the navigation buttons at the top or bottom of the screen as part of the Initialize method, as well as colors for the various features. Below is a brief overview of the methods and variables available in the class.

The class file is included in the demo app source that is attached.

Public Methods and Variables

CurPage - Int
Contains the currently displayed help page. It can be used on rotation to go to the same page as in the demo.

HelpShowing - Boolean
True if the help reader is currently visible.

HideHelp
Removes the help view from sight.


Initialize(A As activity, Top As Boolean, bgColor As Int, txtColor As Int, headingColor As Int, topicColor As Int, fileDir As String)

A - Activity
MUST be Activity.

Top - Boolean
If True, displays the navigation buttons at the top of the screen. False puts them at the bottom.

bgColor - Int
Background color of the help display.

txtColor - Int
Text color for the body text.

headingColor - Int
Page heading color (first line in the file)

topicColor - Int
Topic color (2nd line of file)

fileDir - String
Directory where the help files are stored. Can be dirassets, or anywhere you wish.


ShowHelp
Displays the help system. You do NOT need to call this method after Initialize. It is only used to show the help after the initialization method.


ShowPage(pagenum As Int)
Allows you to specify a page (file) to display. Each page is a separate file in this system.

Using ShowPage(4) will load the file:

help4.txt

and display its contents.
 

Attachments

  • HelpReader.zip
    8.4 KB · Views: 368

moster67

Expert
Licensed User
Longtime User
Thanks for sharing this.

I was actually looking for something similar and this class will help and save me time. I will try to add an image at the top of each page and see if I can combine it with Corwin's AHViewPage-library to enable sliding. Then, it will be perfect for my needs.
 
Top