App Components

The main class of a NeoMAD project must inherit the class. The Application class is the entry point for an application created with the NeoMAD Generic API. This class is used to define the first screen.

The onStart() method is an abstract method that must be overridden. The first screen to be displayed is defined using the Controller.pushScreen() method of the unique Controller instance that is provided in the onStart() method parameter.

Two others classes have a special function in a NeoMAD project:

  • the Res class, which defines constants that identify a project’s resources. This class is generated by NeoMAD (see Resources for more details)
  • the Constants class, which is used to get information about the target and manage conditional compilation (see Constants and conditional coding for more details).


As explained above, the Application class is the application’s only entry point and its code is very simple: it handles the application start and exit, and pushes the first screen.

Example of code:

package com.neomades.helloworld;


public class HelloWorld extends Application {

   public void onStart(Controller controller) {
      // first screen


The NeoMAD Generic API provides a complete set of UI elements that can be combined to design rich application screens. However, for this HelloWorld example, we will start with a very simple screen, using only a vertical layout and a text label.

Screen layouts and UI elements can be defined directly in Java using the classes and methods of the Generic API or in XML using XML Layouts. The latter, which is easier and more convenient, is considered the default. This is why the application structure used by the Eclipse plugin to create new applications is based on this.

First of all, create the helloworld_screen.xml file defining the screen UI:

<?xml version="1.0"?>
<!-- A VerticalLayout represents a group of views arranged
vertically. We want the VerticalLayout to fill all the screen
size and the content to be centered into the VerticalLayout. -->
<VerticalLayout xmlns:xsi="
   <!-- A TextLabel allows to display a simple text on the screen.
   We want the TextLabel size to match the text. -->
   <TextLabel stretchHorizontalMode="MATCH_CONTENT"

Then, declare this XML Layout in the project’s URS file (see URS File for more details):

   <layout name="HELLOWORLD_SCREEN"

Here is the sample code of the Screen class using the XML Layout for its UI:

package com.neomades.helloworld;


* Application page screen
public final class HelloWorldScreen extends Screen {

   protected void, onCreate() {
      // Fill the screen with the HELLOWORLD_SCREEN layout


Constants class

The Constants class allows Java constants that can be used in the application source code and URS file as values or conditions to be defined (see Constants and conditional coding for more details).

For this simple example, no constant is needed, so this class is kept empty:

package com.neomades.helloworld;

import com.neomades.mad.TargetInfo;

public class Constants implements TargetInfo {