HeaderBar

The HeaderBar is a LWUIT component. It allows the user to create a custom HeaderBar which can be added on Form. It is used to create informative and interactive header bars, and has action buttons.

HeaderBar has different implementations such as:

  • Static HeaderBar

  • HeaderBar with spinner

  • HeaderBar with sub-text

  • HeaderBar with icon

  • HeaderBar with icon and spinner

  • HeaderBar with icon and sub-text

  • Interactive HeaderBar

Note:

HeaderBar should be only used with Display.getInstance().setForceFullScreen(true) and should be added as the first component in the Form to get the same look and feel of the platform header bar.

Use the code myForm.setScrollableY(false); to make the HeaderBar sticky (when the Form is in full screen mode).

Figure 1. HeaderBar in a MIDlet

Implementation

  • Create instance of HeaderBar

    • Static HeaderBar

      mHeaderBar = new HeaderBar("View Header");
      myForm.addComponent(mHeaderBar);
      
    • HeaderBar with spinner

      mHeaderBar = new HeaderBar("View Header", true);
      myForm.addComponent(mHeaderBar);
      
    • HeaderBar with sub-text

      mHeaderBar = new HeaderBar("View Header", "View header secondary text");
      myForm.addComponent(mHeaderBar);
      
    • HeaderBar with icon

      // Create an icon
      try {
          img = Image.createImage("/header_icon.png");
      } catch (IOException ex) {
          ex.printStackTrace();
      }
      mHeaderBar = new HeaderBar("View Header", img, false);
      myForm.addComponent(mHeaderBar);
    • HeaderBar with icon and spinner

      // Create an icon
      try {
            img = Image.createImage("/header_icon.png");
          } catch (IOException ex) {
            ex.printStackTrace();
          }                    
      mHeaderBar = new HeaderBar("View Header", img, true);
      myForm.addComponent(mHeaderBar);
    • HeaderBar with icon and sub-text

      mHeaderBar = new HeaderBar("View Header", "View header secondary text", img);
      myForm.addComponent(mHeaderBar);
    • Interactive HeaderBar

      mHeaderBar = new HeaderBar("View Header", img, img);
      myForm.addComponent(mHeaderBar);
      Note:

      For Interactive HeaderBar, you need to pass two images/icons for Button (Unselected and Pressed states).


Last updated 25 July 2013

Back to top

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×