Android Example Wrapping for functionality

This post is aimed at those who may be new to programming concepts as well as b4a.

There are a lot of posts on the forum about wrapping java libraries for use with B4a, but that's not the only use for wrapping.

It is possible to wrap existing B4a/B4j objects to provide additional or specific functionality that you may want reuse throughout an app or all of your apps to create a design standard perhaps.

As an example, in B4j, agrahams message box library provides a function whereby assigning a DialogType, selects an icon for the message box. I thought this is quite cool, so I wrapped the standard B4a message box to provide this functionality.

The attached example shows how, it also shows how to pre-define a message box so you can re-use a particular style of message box without having to set it up every time.

It is written as a class, you can of course compile it to a library so it's available without taking up a module in the IDE.

The demo has no external library dependencies.

If you want to use the images contained in the demo, add the files to the Files tab of your project.
 

Attachments

  • MsgBoxWrapper.zip
    10.9 KB · Views: 504
Last edited:

margret

Well-Known Member
Licensed User
Longtime User
@ Stevel05,

What if you wanted to compile this to a library and include/wrap the images contained in the demo. This way they would be in the library and the user not required to add the files to the Files Tab. Is this something B4A 3.2 can do? I am looking to do the same in a project I am working on but have not had any luck with this. I have about 30 png files I would like to be part of the library.
 

stevel05

Expert
Licensed User
Longtime User
Hi Margret,

I'm not sure this is possible with compile to library, it's interesting though and I'll have to check it out. You can do it with Java libraries but I've not tried it. I suppose theoretically you could create a simple Java library just to contain and access the files, then add that to the project instead of copying the files to the files tab. I'm not sure it would save a lot of effort though.

Steve
 
Last edited:

LucaMs

Expert
Licensed User
Longtime User
@ Stevel05,

What if you wanted to compile this to a library and include/wrap the images contained in the demo. This way they would be in the library and the user not required to add the files to the Files Tab. Is this something B4A 3.2 can do? I am looking to do the same in a project I am working on but have not had any luck with this. I have about 30 png files I would like to be part of the library.


#3 and #5 :(
 

margret

Well-Known Member
Licensed User
Longtime User
Hi Margret,

I'm not sure this is possible with compile to library, it's interesting though and I'll have to check it out. You can do it with Java libraries but I've not tried it. I suppose theoretically you could create a simple Java library just to contain and access the files, then add that to the project instead of copying the files to the files tab. I'm not sure it would save a lot of effort though.

Steve

What about this new resource option. Did I misunderstand what this is for? Below is a quote from Erel.

#AdditionalRes attribute - Makes it possible to wrap Android library projects (projects with resources).
 

LucaMs

Expert
Licensed User
Longtime User
I have tried it and have had no luck with adding these .png files. If this can be made to work, this is a great feature. This way each library can be self contained and not require the user to remember to add other resources in the project. Just add the library and you are good to go.


I agree, obviously.

As you wrote ... "What about this new resource option" ?
 

stevel05

Expert
Licensed User
Longtime User
I've had a more in depth look at this and it doesn't appear possible to achieve this with compile to library. As far as I understand it, you could build a system in Eclipse to do it, but it would require two Eclipse projects, a project that contains the resources and a wrapper. Then you would add the wrapper to your project. Once your project is compiled to a library you would need to distribute 3 libraries.

As it stands it is intended to allow wrapping java libraries that already contain resources.

Currently I don't think there is an alternative to distributing the resource images with your compiled library. I am certainly not an expert in Java, and some who is may be able to find a way to implement this.

It's probably worth creating a request for this in the wish list and getting Erel's take on it.
 
Top