Blackberry UI API provides UI components that provide default layout and behaviours which are consistent with the core Blackberry device applications.
Setting Up a New Blackberry Project
In the previous workshop, I created a new project "HelloWorld". In this workshop, I will create a new project and add a new class "UserInterface" that extends UiApplication. The class is looking like below.
Then, another class "UserInterfaceScreen" is added that extends the MainScreen class.
Variables of various types are declared. The class is looking like below.
Title
The title of the application is setup as shown below.
Managers
The screen is divided into three zones: top, middle and bottom. Horizontal and vertical managers are used to divide the application. The managers aligns up into rows or columns depending in their orientation. This is similar to setting up a components inside a JPanel class in a Java Swing application.
The managers are added in the order they will be displayed on the screen. A vertical manager is built-in on the screen. The code for setting up the managers is below.
Edit and Label Fields
Labels and Edit fields ae added to the middle manager. The code is shown below.
Buttons
Five buttons have been added with different country names. FieldChangedListener is added to the buttons and the fieldChanged method is implemented.
This event performs action when a button is clicked. The code for creating the button and adding FieldChangeListener is shown below.
The buttons are then added to the FieldManager as shown below.
Menu Items
Two menu items are added to the menu - Close and Change Capital. Close shows a dialog as shown in workshop 1 and exits the application. Change Capital allows the user to edit the capital of the selected country. The method for adding menu items is shown below.
Running the application
When the application is run, the following screens are displayed.
As can be seen from the above screen shots of the simulator, the button for India did not appear and the text on Australia button is concatenated.This is because Blackberry screen does not have enough space to display the button in the same row and does not automatically add a new row.
Therefore, to solve this problem, a new FieldManager will need to be added with the buttons added in it.
References:
http://na.blackberry.com/developers/resources/A11_User_Interface_V3.pdf
Setting Up a New Blackberry Project
In the previous workshop, I created a new project "HelloWorld". In this workshop, I will create a new project and add a new class "UserInterface" that extends UiApplication. The class is looking like below.
Then, another class "UserInterfaceScreen" is added that extends the MainScreen class.
Variables of various types are declared. The class is looking like below.
Title
The title of the application is setup as shown below.
Managers
The screen is divided into three zones: top, middle and bottom. Horizontal and vertical managers are used to divide the application. The managers aligns up into rows or columns depending in their orientation. This is similar to setting up a components inside a JPanel class in a Java Swing application.
The managers are added in the order they will be displayed on the screen. A vertical manager is built-in on the screen. The code for setting up the managers is below.
Edit and Label Fields
Labels and Edit fields ae added to the middle manager. The code is shown below.
Buttons
Five buttons have been added with different country names. FieldChangedListener is added to the buttons and the fieldChanged method is implemented.
This event performs action when a button is clicked. The code for creating the button and adding FieldChangeListener is shown below.
The buttons are then added to the FieldManager as shown below.
Menu Items
Two menu items are added to the menu - Close and Change Capital. Close shows a dialog as shown in workshop 1 and exits the application. Change Capital allows the user to edit the capital of the selected country. The method for adding menu items is shown below.
Running the application
When the application is run, the following screens are displayed.
As can be seen from the above screen shots of the simulator, the button for India did not appear and the text on Australia button is concatenated.This is because Blackberry screen does not have enough space to display the button in the same row and does not automatically add a new row.
Therefore, to solve this problem, a new FieldManager will need to be added with the buttons added in it.
References:
http://na.blackberry.com/developers/resources/A11_User_Interface_V3.pdf
No comments:
Post a Comment