This article will help you to understand the usage of StandardTitleBar in blackberry. Follow the example below for more understanding. StandardTitleBar provides a standard title bar component with a standard set of optional title bar components and indicators. The StandardTitleBar component implements the standard set of title bar components for BlackBerry applications. This API is available since BlackBerry Java SDK 6.0. The components that are definable by applications are (from left to right on the title bar).
- Application Icon
- Application Title
- Application Title
- Clock
- Notifications
- Battery Icon (properties)
- Signal Indicator (Wi-Fi and cellular properties)
Each of the components listed above, save the battery icon, has an add and remove method that applications can use to customize the components used by their StandardTitleBar. The battery icon is always part of the title bar.
Applications can however specify the battery icon’s visibility settings using the StandardTitleBar.setPropertyValue(int, int) method.
The setPropertyValue() method can also be used to define the visibility properties of the signal indicator’s Wi-Fi and cellular components.
You cannot change the order of components in the standard title bar. The positions are fixed to the order listed above. The order in which you call the add functions has no bearing on the position or order of these components.
import net.rim.device.api.ui.*; import net.rim.device.api.ui.component.*; import net.rim.device.api.ui.container.*; public class TitleBarDemo extends UiApplication { public static void main(String[] args) { TitleBarDemo theApp = new TitleBarDemo(); theApp.enterEventDispatcher(); } public TitleBarDemo() { pushScreen(new TitleBarDemoScreen()); } } class TitleBarDemoScreen extends MainScreen { public TitleBarDemoScreen() { StandardTitleBar myTitleBar = new StandardTitleBar() .addIcon("my_logo.png") .addTitle("Title Bar Demo") .addClock() .addNotifications() .addSignalIndicator(); myTitleBar.setPropertyValue(StandardTitleBar.PROPERTY_BATTERY_VISIBILITY, StandardTitleBar.BATTERY_VISIBLE_LOW_OR_CHARGING); setTitleBar(myTitleBar); } }