BlackBerry Forums Support Community               

Closed Thread
LinkBack Thread Tools
Old 07-12-2010, 03:37 AM   #1 (permalink)
New Member
Join Date: Jun 2010
Model: 7100T
Carrier: Qwest
Posts: 2
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default ListField Questions

Please Login to Remove!

Hi everyone,

I'm just starting to learn Blackberry development, so sorry if this is a stupid question. I'm following the code samples listed in JDE 4.3.0 Development guide, and I was wondering how to select an item from the list.

I've gotten the lsit to display properly, but I have no idea how to select an item. Also, when the item is selected, how would I clear the screen to draw something completely new?

Old 07-12-2010, 03:49 AM   #2 (permalink)
Knows Where the Search Button Is
Join Date: Jul 2008
Location: India
Model: 9000
Carrier: AirTel
Posts: 29
Post Thanks: 0
Thanked 0 Times in 0 Posts

Please find the custom list field below. Use drawListrow for drawing the contents.

 *  MOPL, 2003-2008
 * Confidential and proprietary.

package customfields;

import java.util.Enumeration;
import java.util.Vector;

import net.rim.device.api.ui.Color;
import net.rim.device.api.ui.DrawStyle;
import net.rim.device.api.ui.Font;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.XYRect;
import net.rim.device.api.ui.component.ListField;
import net.rim.device.api.ui.component.ListFieldCallback;

 * @author Praveen.
 * @version 1.0

public class GLClubsListField extends ListField implements ListFieldCallback {
    private Vector _listData;
    public GLClubsListField (Vector data)  {
        _listData = data;
        setRowHeight(Font.getDefault().getHeight() + 12);
    protected void drawFocus (Graphics graphics, boolean on) {  
        XYRect focusRect = new XYRect();
        int offset = 100;
        if (Graphics.getScreenHeight() > 240) {
            offset = 150;
        drawHighlightRegion(graphics, HIGHLIGHT_FOCUS, true, focusRect.x, focusRect.y, 
                                                            focusRect.width, focusRect.height);            
    protected void drawFocus (Graphics graphics, boolean on) {
            XYRect rect = new XYRect();
            drawHighlightRegion(graphics,HIGHLIGHT_FOCUS,true,rect.x,rect.y,rect.width,graphics.getFont().getHeight() + 1);
    public int moveFocus (int amount, int status, int time) {
        return super.moveFocus(amount, status, time);
    public void onFocus (int direction) {
    protected void onUnFocus () {
    public void refresh () {
    public void drawListRow (ListField listField, Graphics graphics, int index, int y, int width) {
        String[] rowString = (String[]) _listData.elementAt(index);
        graphics.setFont(Font.getDefault().getFontFamily().getFont(Font.PLAIN, 24)); //17
        int selectedIndex = getSelectedIndex();
        if (selectedIndex == index) {
        } else {
        int clubOffset = 100;
        if (Graphics.getScreenHeight() > 240) {
            clubOffset = 150;
        int x = 0;
        graphics.drawText(rowString[1], x, y, DrawStyle.HCENTER, width);
        //graphics.drawText(rowString, (0 - (clubOffset/2)), y, DrawStyle.HCENTER, width);
    public Object get(ListField listField, int index) {
        String rowString = (String) _listData.elementAt(index);
        return rowString;
    public int indexOfList (ListField listField, String prefix, int start) {
        for (Enumeration e = _listData.elements(); e.hasMoreElements(); ) {
            String rowString = (String) e.nextElement();
            if (rowString.startsWith(prefix)) {
                return _listData.indexOf(rowString);
        return 0;
    public int getPreferredWidth(ListField listField) {
        return 3 * listField.getRowHeight();
    protected boolean trackwheelClick (int status, int time) {
        return super.trackwheelClick(status, time);
Praveen K
Closed Thread

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

NEW 250 WATT METAL HALIDE KIT GE LIGHTING Voltage 120/208/240/277/480
NEW 250 WATT METAL HALIDE KIT GE LIGHTING Voltage 120/208/240/277/480  picture Pure Teflon Sheet 8" x 60" x 1/16" Tesla Coil Builders High Voltage, rare find
 Pure Teflon Sheet 8Vintage A.C. & D.C. Voltage Tester by Triplett Electrical Instruments Co. USA
Vintage  A.C. & D.C. Voltage Tester by Triplett Electrical Instruments Co. USA picturePolaris Model 651 40 KV High Voltage DC probe
Polaris Model 651 40 KV High Voltage DC probe picture2-Range Voltage Tester MS8900H
2-Range Voltage Tester MS8900H picture

Copyright 2004-2016
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.