Difference between revisions of "Lab BlackBerry Example"

From CDOT Wiki
Jump to: navigation, search
(2)
(1 add)
Line 11: Line 11:
 
package mypackage;
 
package mypackage;
  
public class MyApp{
+
public class MyApp {
 
     /**
 
     /**
 
     * Entry point for application
 
     * Entry point for application
Line 20: Line 20:
 
}
 
}
 
</source>
 
</source>
 +
 +
You have to extend ''UiApplication''. This class extends the UiApplication class, providing a graphical use interface.
 +
You have to import ''import net.rim.device.api.ui.UiApplication;''
 +
 +
Let us suppose that you want your application to have '''two screens''' and you want to switch from a screen to another using a button.
 +
Thus, you have to define a variable of type Screen to keep track of the Screen object and a variable of type ButtonField.
 +
 +
You need also to importi ''net.rim.device.api.ui.component.ButtonField;''
 +
 
--------
 
--------
  

Revision as of 22:32, 26 February 2011

This lab example allows you to understand the process of building a BlackBerry application using Java Plug-in for Eclipse

Step 1.

File->New->Others->BlackBerry Project Note: If you want really to learn how to build a BB app, then in the wizard choose the Empty Application option. The structure of BB project will be defined, but as the level on code generation, one will get only an empty Java app, with a code similar with this:

package mypackage;

public class MyApp {
    /**
     * Entry point for application
     * @param args Command line arguments (not used)
     */ 
    public static void main(String[] args){
    }
}

You have to extend UiApplication. This class extends the UiApplication class, providing a graphical use interface. You have to import import net.rim.device.api.ui.UiApplication;

Let us suppose that you want your application to have two screens and you want to switch from a screen to another using a button. Thus, you have to define a variable of type Screen to keep track of the Screen object and a variable of type ButtonField.

You need also to importi net.rim.device.api.ui.component.ButtonField;


Step 2.

In the main method create a new instance of the application and make the currently running thread the application's event dispatch thread.

    MyApp theApp = new MyApp();
    theApp.enterEventDispatcher();