Would you like to react to this message? Create an account in a few clicks or log in to continue.


Mon May 20, 2024 1:17 pm
 
Indeks★Forumdns★Latest imagesPencarianPendaftaranLogin

Kirim topik baru   Kirim balasan
 

 How to create a simple BlackBerry application using the BlackBerry Developer Plugin for Eclipse

Go down 
PengirimMessage





VIP

Join date : 01.01.70

How to create a simple BlackBerry application using the BlackBerry Developer Plugin for Eclipse Empty
PostSubyek: How to create a simple BlackBerry application using the BlackBerry Developer Plugin for Eclipse   How to create a simple BlackBerry application using the BlackBerry Developer Plugin for Eclipse EmptyFri Dec 14, 2012 10:03 pm

    https://www.blackberry.com/bdsc/?lang=na#register

    Logged in and registered for Blackberry Developer plugin for Eclipse

    The downloaded plugin is compatible only for Eclipse 3.5 (Galileo)

    How to create a simple BlackBerry application using the BlackBerry Developer Plugin for Eclipse 0

    How to create a simple BlackBerry application using the BlackBerry Developer Plugin for Eclipse 1

    How to create a simple BlackBerry application using the BlackBerry Developer Plugin for Eclipse 4

    Once the installation is complete, launch Eclipse and create a new workspace for your Blackberry projects


    How to create a simple BlackBerry application using the BlackBerry Developer Plugin for Eclipse 7

    Once the workspace has loaded create a new BlackBerry project

    File-New-Other


    How to create a simple BlackBerry application using the BlackBerry Developer Plugin for Eclipse 8


    How to create a simple BlackBerry application using the BlackBerry Developer Plugin for Eclipse 9

    When
    the project loads you will be presented with a BlackBerry getting
    started page. In the future you can open the Getting Started page
    selecting Open BlackBerry Getting Started page from the help
    menu.



    How to create a simple BlackBerry application using the BlackBerry Developer Plugin for Eclipse 11

    I
    have chosen to look at the tutorial called HelloWorld to get a quick
    feel of the development and deployment process I have added a few
    changes to the BlackBerry Helloworld app,but it is essentially based on
    the Hello world sample code.

    How to create a simple BlackBerry application using the BlackBerry Developer Plugin for Eclipse 13

    The
    following shows how to create a BlackBerry® device application that
    displays the text ‘Hello World!’ on the BlackBerry device screen. When a
    BlackBerry device user selects the Close menu item from the menu of the
    Hello World application , the Hello World application displays a dialog
    box with the text ‘Goodbye!’.



    Create a project for the Hello World application

    • On the File menu, click New > Project.
    • Expand the BlackBerry folder.
    • Select BlackBerry project.
    • Click Next.
    • In the Project name field, type SampleApp.
    • Click Next.
    • Click Finish.


    • Specify the Application type and properties for the SampleApp application project
    • In the Project Explorer view, expand a BlackBerry project.
    • Double-click the BlackBerry_App_Descriptor.xml file.
    • Click the Application tab.
    • In the Title field, type SampleApp Sample.
    • In the Version field, type a version number.
    • In the Vendor field, type a vendor name, for example, Steve Robinson
    • In the Application type drop-down list, select BlackBerry Application.
    • Click Close.
    • Click Yes.


    How to create a simple BlackBerry application using the BlackBerry Developer Plugin for Eclipse 14



    Add Java source files to the SampleApp project

    The
    Java source file name must match the name of the public class or
    interface in the file. It must also be located in a folder structure
    that matches its package name. For example, if the package name is
    com.Mycompany.MyClass, you must name the .java file MyClass.java, and
    store it in C:\project\com\mycompany\MyClass.java.


    • In the Package Explorer view, right-click the SampleApp project. Click New > Class.
    • In the Name field, type SampleApp.
    • In the Package field, type com.screv.
    • Next to the SuperClass field, click Browse.
    • In the Choose a type field, type UI.
    • Click UIApplication.
    • Click OK.
    • In the Which method stubs would you like to create section, select the following stubs:
    • public static void main (String[] args)
    • Constructors from superclass
    • Inherited abstract methods
    • Click Finish.

    How to create a simple BlackBerry application using the BlackBerry Developer Plugin for Eclipse 18

    How to create a simple BlackBerry application using the BlackBerry Developer Plugin for Eclipse 20


    Click
    Browse to implement the UIApplication interface.Type UIApplication in
    the Choose a type textbox and a list of matching BlackBerry classes will
    be displayed.


    How to create a simple BlackBerry application using the BlackBerry Developer Plugin for Eclipse 22


    How to create a simple BlackBerry application using the BlackBerry Developer Plugin for Eclipse 23



    Click Finish to see the following class created


    package com.screv;

    import net.rim.device.api.ui.UiApplication;

    publicclass SampleApp extends UiApplication {

    public SampleApp() {
    // TODO Auto-generated constructor stub
    }

    /**
    * @param args
    */
    publicstaticvoid main(String[] args) {
    // TODO Auto-generated method stub

    }

    }

    Since our application needs some extra java classes we are going to use some import statements


    Import Java resources into the SampleApp application (optional depending on yourcode)
    The
    net.rim.device.api.ui package provides the fundamental components for
    constructing the UI of a BlackBerry device application.


    The
    net.rim.device.api.ui.component package provides a library of prebuilt
    interface components and controls for constructing a UI for a BlackBerry
    device application.


    The
    net.rim.device.api.ui.container package provides a library of prebuilt
    interface component managers for constructing a UI for a BlackBerry
    device application.


    The net.rim.device.api.system package provides system-level functionality.

    The
    net.rim.device.api.i18n package provides support for the
    internationalization of a BlackBerry device application.


    In
    Eclipse, in the text editor window, below the line that begins with the
    word package, type the names of the packages to import:

    import net.rim.device.api.ui.*;
    import net.rim.device.api.ui.component.*;
    import net.rim.device.api.ui.container.*;
    import net.rim.device.api.system.*;
    import net.rim.device.api.i18n.*;



    Your
    class should now look like: Since we are not using these new
    resources,Eclipse will warn that there are some unused imports.



    package com.screv;

    import net.rim.device.api.ui.UiApplication;
    importnet.rim.device.api.ui.*;
    importnet.rim.device.api.ui.component.*;
    importnet.rim.device.api.ui.container.*;
    importnet.rim.device.api.system.*;
    importnet.rim.device.api.i18n.*;

    publicclass SampleApp extends UiApplication {

    public SampleApp() {
    // TODO Auto-generated constructor stub
    }

    /**
    * @param args
    */
    publicstaticvoid main(String[] args) {
    // TODO Auto-generated method stub

    }

    }



    The UiApplication class is the base class for all BlackBerry device applications that provide a UI.

    To
    provide a UI, the BlackBerry device application must extend the
    net.rim.device.api.ui.UiApplication class. This class provides methods
    for a BlackBerry device application to register event listeners, manage
    threads, and manage UI components.


    A UI maintains a
    stack of screen objects. As a BlackBerry device application pushes
    screens onto the stack, the UI draws them on top of screens that are
    already on the stack. When a BlackBerry device application pops a screen
    off the stack, the UI redraws the underlying screens as necessary. Only
    the screen that is on the top of the stack receives input
    events.


    Within the main() method, create the SampleApp object and start the event dispatcher:
    SampleApp theApp = new SampleApp();
    theApp.enterEventDispatcher();
    The
    main method for the BlackBerry device application is created
    automatically if you select public static void main (String[ ] args)
    when you add new .java files to the SampleApp project.



    You code should now look like


    package com.screv;

    import net.rim.device.api.ui.UiApplication;
    importnet.rim.device.api.ui.*;
    importnet.rim.device.api.ui.component.*;
    importnet.rim.device.api.ui.container.*;
    importnet.rim.device.api.system.*;
    importnet.rim.device.api.i18n.*;

    publicclass SampleApp extends UiApplication {

    public SampleApp() {
    // TODO Auto-generated constructor stub
    }

    /**
    * @param args
    */
    publicstaticvoid main(String[] args) {
    // TODO Auto-generated method stub

    SampleApp theApp = new SampleApp(); //Create an instance of this class
    theApp.enterEventDispatcher(); //attach an event Dispatcher


    }

    }

    Create a screen for the Sample App application

    Invoking
    super() invokes the constructor of the SampleAppScreen superclass,
    MainScreen. The MainScreen class provides a UI screen that contains a
    title section, a separator element, and a single vertical field manager
    for maintaining a list of fields.


    A LabelField allows a BlackBerry device application to display a label on a UI.

    A
    RichTextField is a read-only text field that you can use to display
    text in a variety of fonts and formats on a BlackBerry device
    screen.


    Invoking add(RichTextField("Hello
    World!")) adds the RichTextField to the Manager object of the
    HelloWorldScreen screen.


    Create a class that extends the MainScreen class.
    final class SampleAppScreen extends MainScreen {
    }Create a constructor for the SampleAppScreen class.
    public SampleAppScreen(){
    }
    In the constructor, add the code to create and display the title and text field.
    super();
    LabelField title = new LabelField("Sample Application", LabelField.ELLIPSIS
    | LabelField.USE_ALL_WIDTH);
    setTitle(title);
    add(new RichTextField("Hello World!"));


    How to create a simple BlackBerry application using the BlackBerry Developer Plugin for Eclipse 26

    I
    chose to create a separate class file for the MainScreen class,it could
    have included in the main body of the SampleApp class.


    How to create a simple BlackBerry application using the BlackBerry Developer Plugin for Eclipse 27

    Eclipse
    warns that LabelField cannot be resolved to a type, so you can
    right-mouse click and add the correct import statement.



    package com.screv;

    import net.rim.device.api.ui.component.LabelField;
    import net.rim.device.api.ui.component.*;

    import net.rim.device.api.ui.container.MainScreen;

    publicclass SampleAppScreen extends MainScreen {

    public SampleAppScreen() {
    // TODO Auto-generated constructor stub
    LabelField title = new LabelField("Sample Application",
    LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);
    setTitle(title);
    add(new RichTextField("Hello World!"));
    }

    public SampleAppScreen(long arg0) {
    super(arg0);
    // TODO Auto-generated constructor stub
    }

    }


    Display a screen in the Sample App application
    In the SampleApp constructor, add the code that displays a screen:
    pushScreen(new SampleAppScreen());

    The
    SampleApp constructor is created automatically if you select
    Constructors from superclass when you add new .java files to the Sample
    App project.


    The pushScreen() method is inherited
    from the UiApplication class and pushes a screen onto the display stack
    and paints it. The BlackBerry Java®Virtual Machine maintains screens in a
    display stack.


    package com.screv;

    import net.rim.device.api.ui.UiApplication;
    importnet.rim.device.api.ui.*;
    importnet.rim.device.api.ui.component.*;
    importnet.rim.device.api.ui.container.*;
    importnet.rim.device.api.system.*;
    importnet.rim.device.api.i18n.*;

    publicclass SampleApp extends UiApplication {

    public SampleApp() {
    // TODO Auto-generated constructor stub
    pushScreen(new SampleAppScreen());
    }

    /**
    * @param args
    */
    publicstaticvoid main(String[] args) {
    // TODO Auto-generated method stub

    SampleApp theApp = new SampleApp(); //Create an instance of this class
    theApp.enterEventDispatcher(); //attach an event Dispatcher


    }

    }
    Display a message when the Hello World application closes
    The
    onClose() method is inherited from the Screen class and indicates to a
    BlackBerry device application that a close event has occurred.


    The
    Dialog.alert() method creates an alert dialog box that a BlackBerry
    device application can use to notify a BlackBerry device user of an
    event or important information. The dialog displays an exclamation mark
    bitmap.


    In the SampleScreen class, override the onClose()method to create an alert dialog box and display text.
    public boolean onClose()
    { Dialog.alert("Goodbye!");
    System.exit(0);
    return true;
    }


    package com.screv;

    import net.rim.device.api.ui.component.LabelField;
    import net.rim.device.api.ui.component.*;

    import net.rim.device.api.ui.container.MainScreen;

    publicclass SampleAppScreen extends MainScreen {

    public SampleAppScreen() {
    // TODO Auto-generated constructor stub
    LabelField title = new LabelField("Sample Application",
    LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);
    setTitle(title);
    add(new RichTextField("Hello World!"));
    }

    public SampleAppScreen(long arg0) {
    super(arg0);
    // TODO Auto-generated constructor stub
    }

    publicboolean onClose()
    { Dialog.alert("Goodbye!");
    System.exit(0);
    returntrue;
    }
    }



    Test the Hello World application using the BlackBerry Smartphone Simulator
    On the Run menu, click Run As > BlackBerry Simulator.
    On the BlackBerry Smartphone Simulator, open the Downloads folder.
    Click the Hello World application. The Sample App application displays the text Hello World!.
    On
    the menu of the Hello World application, click Close. The Sample App
    application displays a dialog box with the text Goodbye!.

    Click OK.

    How to create a simple BlackBerry application using the BlackBerry Developer Plugin for Eclipse 35


    the
    Simulator will take a few minutes to load up, once loaded navigate to
    the Downloads folder to find the Sample application


    You need to click on the BlackBerry button as shown below

    How to create a simple BlackBerry application using the BlackBerry Developer Plugin for Eclipse 37

    How to create a simple BlackBerry application using the BlackBerry Developer Plugin for Eclipse 45

    Click on the SampleApp application

    How to create a simple BlackBerry application using the BlackBerry Developer Plugin for Eclipse 51


    Result


    How to create a simple BlackBerry application using the BlackBerry Developer Plugin for Eclipse 55


    Sample Code:



    How to create a simple BlackBerry application using the BlackBerry Developer Plugin for Eclipse 59How to create a simple BlackBerry application using the BlackBerry Developer Plugin for Eclipse 59

    Eclipse Project Interchange
Kembali Ke Atas Go down
 
How to create a simple BlackBerry application using the BlackBerry Developer Plugin for Eclipse
Kembali Ke Atas 
Halaman 1 dari 1
 Similar topics
-
» How to create a simple BlackBerry application using the BlackBerry Developer Plugin for Eclipse

Permissions in this forum:Anda dapat menjawab topik
 :: コンピュータ ( Computer ) :: プログラミングおよびネットワーキング(Programming & Networking)-
Kirim topik baru   Kirim balasanNavigasi: