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

Santinelli Nidek LE7070 Motherboard
Santinelli Nidek LE7070 Motherboard pictureGORING KERR 114-6504/114-6506 MOTHERBOARD *NEW NO BOX*
GORING KERR 114-6504/114-6506 MOTHERBOARD *NEW NO BOX* pictureYASKAWA A1000 YPHT31600-1D / ETC740110-S1022 / JVOP-180 Motherboard & Keypad 1A
YASKAWA  A1000 YPHT31600-1D / ETC740110-S1022 / JVOP-180 Motherboard & Keypad 1A pictureIBASE IB865R IB865-R Motherboard #RS01
IBASE IB865R IB865-R Motherboard #RS01 picture1PC USED Siemens MM420 inverter/Motherboard/CPU board/control board Tested #RS01
1PC USED Siemens MM420 inverter/Motherboard/CPU board/control board Tested #RS01 picture

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