Android Tutorial Custom class templates

Discussion in 'Libraries developers questions' started by Erel, Mar 12, 2018.

  1. Erel

    Erel Administrator Staff Member Licensed User

    Starting from B4A v8.0 it is possible to include custom class templates inside your libraries. Note that it will also be added to B4J and B4i.

    You can include multiple templates.

    There are two steps:
    1. Add the template files to the project. File extension must be .b4x_excluded.
    For example B4J jServer library now includes the three server handlers:

    [​IMG]

    2. Declare them with the new @CustomClasses annotation:
    Code:
    @CustomClasses(values = {
           @CustomClass(name = 
    "Server Handler", fileNameWithoutExtension = "server_handler"),
           @CustomClass(name = 
    "Server Filter", fileNameWithoutExtension = "server_filter"),
           @CustomClass(name = 
    "Server WebSocket", fileNameWithoutExtension = "server_websocket")
    })
    @Version(2.90f)
    @ShortName("Server")
    @DependsOn(values={"jetty_b4j", "c3p0-0.9.5.2", "c3p0-oracle-thin-extras-0.9.5.2"
           ,"mchange-commons-java-0.2.11", "json"})
    public class ServerWrapper {
    If you are using SLC to build the library then you should put the files in the 'additional' folder.

    The jar structure should be:

    [​IMG]

    Make sure to use BADoclet v1.07+. The updated doclet is available inside SLC.

    The generated XML should end with:
    Code:
    <customClass>name:Server Handler, filenamewithoutextension:server_handler</customClass>
        <customClass>name:
    Server Filter, filenamewithoutextension:server_filter</customClass>
        <customClass>name:
    Server WebSocket, filenamewithoutextension:server_websocket</customClass>
    </root>
     
    alwaysbusy and DonManfred like this.
  2. Star-Dust

    Star-Dust Expert Licensed User

    So it is possible to create it only in Java. It is not possible with the B4A libraries
     
  3. DonManfred

    DonManfred Expert Licensed User

    You can check the file "themes.jar" inside the internal Library folder.

    Rename it to themes.zip and have a look at it.

    Just create a zip with just the templates in it (using the correct filenames (Extension)...
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Start a new thread in the questions forum and I'll explain how it can be done. As I wrote in the release thread it is quite simple.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice