Android Question Is there a Tutorial on creating B4A libraries

Gary Milne

Active Member
Licensed User
Longtime User
I cannot find much on this topic. I seems that I must create a blank project, add a new module, add Subs to the module and then compile to library.

My library will work with the GUI so I'm not clear on what I need to do for declarations of GUI elements and how I load and unload it into a current activity.

It's probably fairly easy and all I need is a sample to look at and I'm sure I can figure it out pretty quickly.

Any pointers appreciated.
 

eps

Expert
Licensed User
Longtime User
Upvote 0

Gary Milne

Active Member
Licensed User
Longtime User
I will take a look at those. I did see those references but they were always in connection with B4J which I assumed would not be relevant to me but perhaps they are alike. I don't know anything about B4J.

Thanks for taking the time to respond.
 
Upvote 0

Gary Milne

Active Member
Licensed User
Longtime User
What I wanted to do was write a simple Help UI. All it would have is a full screen panel, title, HTML body text and a close button. I could then use this library in various parts of my app (and future apps) to display help to the user. Pretty simple to write in regular B4A.

I was under the impression that Classes have limits when dealing with the UI but a quick look at Chapter 11 makes it look like they can have UI components of their own, it's accessing UI components of the parent Activity that is limited\complex. Is that a fair statement?

It appears that a Class would be a good way of doing it. Would you agree from my brief description of what I want to do?
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
The easiest way is a Class module which is compiled to a Library.
You could use a Panel with all the needed views on it and call it as a CustomView from the 'main' program.
... it's accessing UI components of the parent Activity that is limited\complex. Is that a fair statement?
No.
You can add any view in the class code. You can also 'transmit' events generated by views inside the class to event routines in the main program like on page 117 in the User's Guide.

EDIT: The page is 171 and not 117.
 
Last edited:
  • Like
Reactions: eps
Upvote 0

Gary Milne

Active Member
Licensed User
Longtime User
Thanks Klaus, do you know of any samples you could direct me too. I get the concept but the implementation details are fuzzy. It seems like a great way to package re-usable dialogs for a low maintenance\reliable approach so it seems very attractive if I can get it to work.

I looked at page 117 of the users guide and it is about Nine Patch Drawables but I could not see the correlation but possibly because I have not used the Reflection library much.

Thanks for your help. My app is nearly done and I'm just doing some housekeeping and smoothing the rough edges.
 
Upvote 0

Gary Milne

Active Member
Licensed User
Longtime User
Sorry, the page is 171 !
Can you post a layout of the help panel.
Ah yes, I forget how much good stuff is in that document. I tend to go to the book, the website and forget about the Users Guide. I think there is enough there for me to get it working but here is the simple layout I created to test with.
 

Attachments

  • Help.zip
    11.8 KB · Views: 113
Upvote 0

Gary Milne

Active Member
Licensed User
Longtime User
Thanks for taking the time to do that Klaus, it all makes sense. I tried to get it to load a local file (it's for a help system) using the syntax HelpScreen.Show("file:///android_asset/help1.htm"). Even though the file is there and I can see it in the Files tab. It gives me the error ERR_FILE_NOT_FOUND. I even test it's existence with File.Exists which it passes but then will not load. Is my syntax incorrect?
 
Upvote 0

Gary Milne

Active Member
Licensed User
Longtime User
Thank you both. I was doing my testing in Rapid Debug mode so encountered the issue addressed by the above link in Erel's post, which was why it was not working. With that addition it works as expected and I think it will be a versatile addition. Once I have added a few features to it I will post it back for others to use.
 
Upvote 0
Top