Would you like to tell us how we are doing?

You bet No thanks

Sorry about the red box, but we really need you to update your browser. Read this excellent article if you're wondering why we are no longer supporting this browser version. Go to Browse Happy for browser suggestions and how to update.

Picture scroll field sample app

The picture scroll field sample application demonstrates how to create and customize a row of images that BlackBerry device users can scroll through on their screens. You can specify different highlight styles and turn the center lens on and off to demonstrate different configurations of a PictureScrollField object. If you click an image, the sample application displays a simple message.

File name

Description

PictureScrollFieldDemo.java

This file defines the PictureScrollFieldDemo class.

The PictureScrollFieldDemo class extends the UiApplication class to support a UI and contains the following constructor and methods:

  • main(String[] args): provides the entry point to the sample application and starts the main thread for the application using the enterEventDispatcher() method from UiApplication
  • PictureScrollFieldDemo(): constructs a new PictureScrollFieldDemo object and creates a PictureScrollFieldDemoScreen object and displays it

PictureScrollFieldDemoScreen.java

This file defines the PictureScrollFieldDemoScreen class.

The PictureScrollFieldDemoScreen class extends the MainScreen class to support screen characteristics that are common to standard BlackBerry device applications, implements the FieldChangeListener interface to support the handling of field change events, and contains the following constructor and methods:

  • PictureScrollFieldDemoScreen(): constructs a new PictureScrollFieldDemoScreen object, and contains the code that initializes an array of scroll entries, a PictureScrollField object, a choice field for selecting a highlight style, and a check box for turning the center lens on and off
  • onSavePrompt(): overrides the MainScreen.onSavePrompt() method with the functionality to suppress the dialog box that prompts the BlackBerry device user to save, because the sample application does not store persistent data
  • navigationClick(int status, int time): overrides the Screen.navigationClick(int status, int time) method with the functionality to make a dialog box appear if a click event occurs on an entry in the PictureScrollField
  • touchEvent(TouchEvent message): overrides the Screen.touchEvent() method with the functionality to make a dialog box appear when a TouchEvent.CLICK event occurs on an entry in the PictureScrollField object
  • fieldChanged(Field field, int context): overrides the FieldChangeListener.fieldChanged(Field field, int context) method to be notified of a change in the screen's highlight style ChoiceField, and change the highlight style of the screen's PictureScrollField object accordingly

This sample features the following classes:

net.rim.device.api.ui.extension.component.PictureScrollField

This class represents a row of images that a BlackBerry device user can browse and click by scrolling side to side. This class provides methods and fields that you can use to define the physical appearance of a PictureScrollField object. You define the content and highlight style of a PictureScrollField object in two of its nested classes, ScrollEntry and HighlightStyle.

The sample application demonstrates how this class uses the ScrollEntry and HighlightStyle nested classes, and how to define the border, background, label visibility, and center lens for the PictureScrollField object.

net.rim.device.api.ui.extension.component.PictureScrollField.HighlightStyle

This class specifies the behaviour of the highlight effect that occurs when a BlackBerry device user focuses on an image in a PictureScrollField object. You define the highlight style by specifying one of the fields that are provided with the class.

In the sample application, you can choose from several highlight styles.

net.rim.device.api.ui.extension.component.PictureScrollField.ScrollEntry

This class represents the individual image entries in a PictureScrollField object. You can specify the images as well as the text for the labels and callouts that appear when a BlackBerry device user focuses on an image.

The sample application creates an array of scroll entries and passes it to a PictureScrollField object.

Install the sample app

Visit www.blackberry.com/go/picturescrollfieldsample to download the sample application.

Extract the picturescrollfielddemo.zip file.

On the taskbar, click Start > Programs > Research In Motion > BlackBerry JDE 5.0 > JDE.

Open the workspace that you want to add the sample application to.

In the workspace tree, right-click the project that you want to add the sample application to.

Click Add project to <workspace directory>.

In the Add project to <workspace> dialog box, navigate to the folder where you extracted the sample application.

Click the PictureScrollFieldDemo.jdp file.

Click Open.

The sample app is also available in github.

Run the sample app

In the workspace where you added the picturescrollfielddemo project, right-click picturescrollfield.

Click Build project.

On the taskbar, click Start > Applications > Research in Motion > BlackBerry JDE 5.0 > Device Simulator.

On the Home screen of the BlackBerry Smartphone Simulator, click the Downloads folder.

Click the PictureScrollFieldDemo icon.