`
wuhua
  • 浏览: 2105749 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

User Interface (UI)

阅读更多

Overview

This document describes how to create UIs for BlackBerry device applications. For more information, see the following sections:

UI frameworks

You can create UIs for the BlackBerry device using the following frameworks: BlackBerry UI APIsMobile Information Device Profile APIs, and Scalable Vector Graphics APIs.

BlackBerry UI APIs

Packagesnet.rim.device.api.uinet.rim.device.api.ui.autotextnet.rim.device.api.ui.componentnet.rim.device.api.ui.containernet.rim.device.api.ui.decornet.rim.device.api.ui.text,net.rim.blackberry.api.spellchecknet.rim.device.api.browser.fieldnet.rim.device.api.lbs

To create UI applications that are optimized to run on the BlackBerry platform, as well as interact efficiently with core device applications (such as mail, phone, and browser applications), use the BlackBerry UI APIs. For a detailed overview on the BlackBerry UI APIs, see the package overview.

Applications using the BlackBerry UI APIs are not portable to other mobile devices.

Mobile Information Device Profile (MIDP) APIs

Packagesjavax.microedition.lcdui, javax.microedition.lcdui.gamejavax.microedition.midlet

MIDlets are applications that use only the standard Mobile Information Device Profile (MIDP) APIs and Connected Limited Device Configuration (CLDC) APIs. The Blackberry currently supports both MIDP version 1.0 (JSR 37) and 2.0 (JSR 118). MIDlets run on BlackBerry� devices and other devices that support the Java� Micro Edition (Java ME) platform.

For a detailed overview on the MIDP UI APIs, see the package overview.

Scalable Vector Graphics (SVG)

Packagesorg.w3c.domorg.w3c.dom.eventsorg.w3c.dom.svg , net.rim.plazmic.mediaengine , net.rim.plazmic.mediaengine.io

SVG is a text-based markup language similar to HTML that represents 2D vector graphics, animation, and interactivity. SVG support was added to J2ME with JSR 226. Vector graphics rely on geometrical primitive objects such as lines, circles, polygons. Since they are based on geometry, vector graphics can be easily manipulated without loss of accuracy. When developing for mobile devices, SVG has the advantage of automatically scaling to the screen resolution on the device. In addition, you can use SVG for both MIDlets and BlackBerry API applications.

There are two ways to use SVG in your applications on a BlackBerry device:

Advantages of the BlackBerry API UI framework [back to top]

While you can use either MIDP or BlackBerry UI APIs, consider the following advantages that are available when using the BlackBerry API UI framework to create UIs.

Increased display options

A major difference between the MIDP and BlackBerry API UI frameworks is the number of display options permitted. MIDP separates UI components into high and low-level APIs. When using the high-level APIs to ease portibility between mobile device platforms, only one Displayable object, which represents the device screen, can be viewed at one time. As a result, you can only view certain types of UI components at a time. For example, you cannot combine a List with another type of UI component, such as a Gauge.

In contrast, the BlackBerry UI's Screen object, you can combine any number of field objects together into a Manager, such as a ListFieldGaugeField, and numerous BitmapField objects. CertainDisplayable objects in MIDP (such as List and Alert) are considered Field components in the BlackBerry UI. In this respect, the BlackBerry UI is more extensible, enabling you to create complex application interfaces more efficiently.

 

Using Custom Fields

Field is an object container in the BlackBerry APIs that holds and lays out a particular type of data for display in the UI. The BlackBerry APIs provide a number of useful ways to display particular types of data in a Field, none of which can be embedded into a MIDlet . For example:

  • DateField allows you to store a date and display it in several formats in a Field (such as 2008/11/17)
  • MapField allows you to render a map in a Field
  • BrowserContent allows you to store web content in a Field

In addition to the useful Field types defined in the BlackBerry UI, you can create your own. The BlackBerry UI provides you with the functionality to extend the basic Field to create any type of field.

Click here for a code sample on creating a custom text field that contains (non-editable) separate pieces of text.

To create similar objects using the MIDP APIs, you can use the CustomItem class. However, unlike Field extensions, this approach does not allow you to easily modify display options such as borders, layout, and theming.

Controlling layout

The BlackBerry API provides layout managers that offer flexibility in displaying Fields. You declare a layout manager at the top level of your screen, and then add field components to it. Since layout managers are types of Field, they can be embedded in other layout managers.

Click here for a code sample on creating a custom layout for a Screen.

The closest relation to a layout manager in the MIDP API is Form. It vertically aggregates Item objects on the display, but does not allow you to change the order in which the items are displayed. As a result, if your interface requires a specific ordering, involves frequent scrolling between fields or a horizontal field layout, BlackBerry API layout managers are more suitable.

Alerting using PopUpScreens

The BlackBerry UI has two main types of Screen objects: PopupScreen, which is subclassed by Dialog and Status, and FullScreen, which is subclassed by MainScreen.

You can use the BlackBerry UI to display information that is supplementary to your application in a pop-up screen without interrupting the flow of the application. As a result, you do not have to leave the main screen, and then return to it later. In addition, you can prioritize which PopupScreen objects get pushed to the top of the display stack using pushGlobalScreen(Screen, int, int).

Because MIDP is intended for devices with minimal displays, such as mobile phones, Alert object functions differently from PopupScreen in the BlackBerry APIs. Alert objects are Screens that use the entire display when they are invoked.

Creating Menus

The MIDP UI prioritizes commands according to the device specifications, and assigns certain commands to soft keys (non-hard-coded keys on the mobile device). BlackBerry devices organize commands on a menu that is accessible by clicking the trackwheel/trackball. You can specify the order of menu items and the menu item that is selected by default when the menu opens. In addition, you can add or remove menu items depending on the screen or application state when the menu displays.

Using Listeners

The MIDP UI includes one default type of listener, CommandListener. You can only register one CommandListener for each Displayable object. After you register a CommandListener with theDisplayable object, you can write code to perform an action when that object is selected. For example, you can assign a command listener to a Form, and then perform an action when the user selects an item in the Form. The MIDP UI also contains functions for basic event handling that is based on keyboard input.

The BlackBerry UI offers a flexible implementation of listeners, based on the more involved level of components that can be structured on a screen. The BlackBerry UI contains a generic event listener model that enables you to implement listeners for many types of events, such as when a user presses a key or clicks the trackwheel/trackball, or field, focus, and scrolling changes.

Handling interactions between MIDlets and BlackBerry Java applications [back to top]

When you create UI applications using MIDlets, you can invoke a variety of BlackBerry APIs to provide specific functionality only available for BlackBerry Java applications. For example, if your MIDlet UI application requires the ability to notify users when specific events take place, it can invoke the methods available in the net.rim.device.api.notification package. As a result, however, this makes your application not portable to other mobile devices.

Most BlackBerry Java application classes can be invoked from MIDlet UI applications. However, do not attempt to use any classes in the net.rim.device.api.ui package. Doing so is unsupported, and, due to potential incompatibility with future BlackBerry handheld software releases, may result an unpredictable user experience.

Managing UI application threads [back to top]

All UI applications written using the BlackBerry UI framework contain one event dispatcher thread, which you invoke using Application.enterEventDispatcher(). After a Screen object is pushed onto the display stack, make all modifications either on the event dispatcher thread, or on a background thread while holding the event lock. This is for performance reasons and to avoid concurrency issues; attempting to make changes using a non-thread not synchronized on the event lock throws RuntimeException.

Using a background thread with the Event Lock [back to top]

Use background threads to access the UI by acquiring the event lock for a short time, without interfering with processing by the event dispatcher. Invoke Application.getEventLock() on the background thread to retrieve the event lock, and then synchronize this object to serialize access to the UI. You should only hold this lock for short periods of time because the event dispatcher thread is paused. An application should never call notify() or wait() on this object.

For example, in a timer task, you could write code in the following method:

Click here for a code sample on acquiring an event lock.

Using the Event Dispatcher Thread [back to top]

To use the event dispatcher thread on all Fields on the display stack, create a class that implements the Runnable interface. You can then invoke its run() method on the event dispatcher thread using one of the following methods (each found in net.rim.device.api.system.Application):

  • Use invokeAndWait(Runnable runnable) to queue run() to be called on the event dispatcher thread. This call blocks and does not return until the run() method is completed.
  • Use invokeLater(Runnable runnable) to queue run() to be called on the event dispatcher thread after all pending events are processed. This method returns immediately, instead of blocking until run() returns.
  • Use invokeLater(Runnable runnable, long time, Boolean repeat) to invoke run() on the event dispatcher thread after a specified amount of time. This method returns immediately, instead of blocking until run() returns. In this case, time specifies the number of milliseconds to wait before adding Runnable to the event queue. If repeat returns true, the Runnable is added to the event queue every millisecond.

Before a Field or Screen is added or after it is removed (popped-off) from the display stack, any thread can modify the Screen object.

Click here for a code sample for invoking invokeLater(Runnable runnable) to update a screen on the event thread.

Using Modal Screens [back to top]

Screen objects are pushed to the display stack using the pushScreen() and pushModalScreen() methods of the UiApplication class. Because pushModalScreen() blocks until the screen is removed from the display stack (where pushScreen() returns immediately), the order of operations is crucial when you use modal screens. Do not invoke pushModalScreen() before starting the event dispatcher thread; doing so throws RuntimeException. Note that other methods, such as Dialog.inform and Dialog.alert from Dialog class, also use pushModalScreen().

The following code sample shows how to properly display a modal and non-modal screen in an efficient manner.

Click here for a code sample on efficiently displaying a modal and non-modal screen.


Copyright 1999-2009 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.

分享到:
评论
1 楼 pdw2009 2010-09-04  
翻译成中文吧

相关推荐

    18 The Fundamentals of User Interface (UI) Design for Mobile

    在本专题“18 The Fundamentals of User Interface (UI) Design for Mobile”中,我们将深入探讨移动UI设计的基本原则和技巧,尤其关注如何利用Java进行有效的实现。 一、移动UI设计的重要性 移动设备的屏幕尺寸和...

    UI Guidelines for CRM WebClient User Interface

    UI Guidelines for CRM WebClient User Interface

    User Interface Design for Programmers (全本)

    本书通过简洁实用的方法帮助读者掌握UI设计的核心原则,并将其应用于实际项目中。 #### 二、章节内容概览 本书共分为18章,覆盖了用户界面设计的基础到高级层面的内容。 1. **控制环境使你快乐**:介绍了创造一个...

    jQuery UI 1.8 The User Interface Library for jQuery

    首先,从标题“jQuery UI 1.8 The User Interface Library for jQuery”中,我们可以知道这一版本是专为jQuery设计的用户界面库,它为网页开发者提供了一组丰富的界面组件,这使得创建动态网页变得更加简单高效。...

    UIKit User Interface Catalog.pdf

    ### UIKit User Interface Catalog知识点概述 本文档主要介绍了iOS开发中UIKit框架下的各种用户界面元素及其使用方法、行为特征以及外观自定义等内容。UIKit是iOS应用开发的基础库之一,提供了丰富的UI组件来帮助...

    Microsoft Windows CE User Interface Services Guide用户界面服务指南-part2

    《Microsoft Windows CE User Interface Services Guide用户界面服务指南-part2》是针对使用Embedded Visual C++(EVC)开发Windows CE平台上用户界面的专业参考资料。本部分主要深入探讨了如何利用EVC进行用户界面...

    iOS 7 UIKit User Interface Catalog

    在iOS 7的UIKit框架中,苹果提供了一份详尽的人机交互指南——**iOS 7 UIKit User Interface Catalog**,该指南全面覆盖了iOS应用程序开发中常用的各种UI元素及其配置方法。本文将根据给定的内容摘要对其中涉及的...

    jQuery UI 1.7 The User Interface Library for jQuery

    jQuery UI 1.7 The User Interface Library for jQuery.jquery-ui-1-7-sample-chapter-3-tabs.解压密码 csdn

    User Interface Design For Programmers

    人机交互(Human-Computer Interaction,简称HCI)与人机界面(User Interface,简称UI)设计是现代软件开发中不可或缺的部分,它们直接影响到软件产品的用户体验和用户满意度。 首先,我们要理解人机交互的基本...

    User Interface Design and Implementation

    在计算机科学中,用户界面(UI)设计是至关重要的,它关乎到软件或系统的易用性、效率以及用户体验。这份教案将深入探讨用户界面设计的原则、方法和技术,并阐述如何将这些理论付诸实践。 一、用户中心设计 用户...

    jQuery UI 1.7, The User Interface Library for jQuery.pdf

    《jQuery UI 1.7, The User Interface Library for jQuery》是关于jQuery UI库的一本权威指南,由Dan Wellman撰写,旨在帮助开发者构建高度交互式的Web应用程序。jQuery UI 是一个基于jQuery的开源库,提供了丰富的...

    User Interface Summary

    在IT行业中,用户界面(User Interface,简称UI)是系统与用户进行交互和信息交换的媒介,是任何软件或应用程序的核心组成部分。一个优秀的用户界面设计能够提供直观、高效且易于理解的用户体验,使用户能够轻松地...

    Jquery UI 1.8 The user interface library

    标题和描述中提到的知识点是关于JQuery UI 1.8。JQuery UI 是一个基于JQuery的JavaScript库,它为Web开发者提供了丰富的交互式界面组件和特效,以方便快速构建出美观且功能丰富的网页应用程序。JQuery UI 1.8版本是...

    Android.User.Interface.Development.Beginners,超清晰android界面开发电子书(老外写的)

    总之,《Android User Interface Development for Beginners》是一本全面而深入的教程,涵盖了Android UI开发的所有基础知识,无论你是零基础的新手还是希望提升界面设计能力的开发者,都能从中受益匪浅。...

    最新SAP用户界面技术路线图sap user interface road map 2015.11

    SAP用户界面技术路线图(SAP User Interface Road Map 2015.11)是一份由SAP公司发布的文件,主要阐述了该公司对用户界面技术的未来发展计划和规划。在这份文件中,SAP为用户提供了关于其产品演进和技术发展的路线图...

Global site tag (gtag.js) - Google Analytics