Open main menu

CDOT Wiki β

Teams Winter 2011/team1/BlackBerry/Add Elements to View Screen

Revision as of 13:27, 21 March 2011 by Azea (talk | contribs)

5. Add Elements to View Screen

5.1. Create new Class InfoScreen that extends MainScreen as inner class in MyScreen:

  private final static class InfoScreen extends MainScreen {
    InfoScreen(Student student) {
      //add elements here

5.2. Set the title:


5.3. Add the text field:

  BasicEditField emailField = new BasicEditField("email: ",student.getEmail(),50,Field.NON_FOCUSABLE);

5.4. Format this field:

  Border roundedBorder = BorderFactory.createRoundedBorder(new XYEdges(10, 10, 10, 10), Border.STYLE_SOLID);
  Background solidBackground = BackgroundFactory.createSolidBackground(Color.CORAL);

5.5. Override the ,code>close()</code> method:

  public void close() {

5.6. Some mehtods inside the MyScreen should be overriden.
In order to show the View screen override the invokeAction() method:

   public boolean invokeAction(int action) {       
        if(action == ACTION_INVOKE) {        
            return true;
        return super.invokeAction(action);

5.7. If enter was hit we want to show the view Screen:

   protected boolean keyChar(char key, int status, int time) {
        if (key == Characters.ENTER) {
            return true;    
        return super.keyChar(key, status, time);

5.8. Override the onSavePrompt() to suppress the save dialog:

   public boolean onSavePrompt() {       
        return true;

5.9. Create the method to push the view screen into the stack:

   private void displayInfoScreen(){
        // Retrieve the selected Country and use it to invoke a new InfoScreen      
        Student student = (Student)_keywordFilterField.getSelectedElement();
        if(student!= null) {           
            InfoScreen infoScreen = new InfoScreen(student);

5.10. Run the application and click on a student: