Blackberry Listfield问题

时间:2012-11-01 08:23:09

标签: blackberry listfield

我正在开发一个OS 5.0中的应用程序,其中包含一个显示结果的表格,为此我使用了一个非常流行的代码,它实现了一个Listfield和一个TableRowManager。每一行都比屏幕宽度宽,所有数据都显示出来,它通常运行良好......除了一个非常烦人的傻笑。

如果我向右滚动,可以通过滑动手势或使用导航按钮,屏幕按预期滚动,但向下滚动到下一行,焦点返回到该行的最左侧。我需要做的是保留listfield中的位置。在调用屏幕中(添加了此Listfield),Listfield将添加到VerticalFieldManager中。然后将其添加到Horizo​​ntalFieldManager。

我的Horizo​​ntalFieldManager启用了HORIZONTAL_SCROLL,而包含Listfield的VerticalFieldManager却没有。添加它没有任何效果。每个管理器使用参数NO_SCROLL_RESET但滚动确实被重置。

我有点像BB编码的新手,但我很确定我需要覆盖某种方法,但哪一个让我望而却步。我在这里和其他论坛上一遍又一遍地搜索,但无济于事。我希望有人遇到同样的问题,并有解决方案。

以下是代码示例(不是很小,我很害怕)

首先,我的屏幕:

package Screens;

import java.util.Vector;

import net.rim.device.api.system.Display;
import net.rim.device.api.ui.Color;
import net.rim.device.api.ui.DrawStyle;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.FieldChangeListener;
import net.rim.device.api.ui.Font;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.Manager;
import net.rim.device.api.ui.Screen;
import net.rim.device.api.ui.Ui;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.HorizontalFieldManager;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.container.VerticalFieldManager;
import net.rim.device.api.ui.decor.BackgroundFactory;
import ListFieldObjects.TableList;
import Main.HomeGrid;
import Main.Stoppable;
import Main.TableLayoutManager;

public class TableScreen extends MainScreen implements FieldChangeListener 
{
VerticalFieldManager vfmScreen, vfmTable, vfmPlanned, vfmActual;
HorizontalFieldManager hfmTableTitle;
public Vector vectorData;
TableList tableList;
int numData=0;
int subHeight = 0;
LabelField lblTableTitle, lblField01, lblField02, lblField03, lblField04, lblField05, lblField06, lblField07, lblField08, lblField09;
Screen currScreen;
boolean refresh=false;
public static boolean _stop = false;
TableLayoutManager tlmNumData;
Font buttonFont;
static int widthField01=65, widthField02=150, widthField03=150, widthField04=150, widthField05=150, widthField06=150, widthField07=150, widthField08=150, widthField09=150;


public TableScreen()
{
    super(USE_ALL_WIDTH | USE_ALL_HEIGHT);

    vfmScreen = new VerticalFieldManager(VerticalFieldManager.USE_ALL_WIDTH | VerticalFieldManager.NO_SCROLL_RESET);
    vfmScreen.deleteAll();

    switch (Display.getWidth()) {
        case 640:
            subHeight = 40;
            buttonFont = Font.getDefault().derive(Font.SANS_SERIF_STYLE | Font.BOLD, 6, Ui.UNITS_pt);
            break;
        default:
            subHeight = 30;
            buttonFont = Font.getDefault().derive(Font.SANS_SERIF_STYLE | Font.BOLD, 7, Ui.UNITS_pt);
            break;
    }

    _stop = false;

    HorizontalFieldManager hfmTitle = new HorizontalFieldManager(HorizontalFieldManager.USE_ALL_WIDTH | HorizontalFieldManager.NON_FOCUSABLE) {
        protected void sublayout( int maxWidth, int maxHeight)
        {
            int width = Display.getWidth();
            int height = subHeight;
            super.sublayout( width, height);
            super.setBackground(BackgroundFactory.createSolidBackground(0x00fec200));
            setExtent( width, height);
        }
    };
    hfmTitle.setPadding(0, 1, 0, 1);

    // create a label
    LabelField title = new LabelField("Data", LabelField.USE_ALL_WIDTH | DrawStyle.HCENTER);
    title.setFont(Font.getDefault().derive(Font.SANS_SERIF_STYLE | Font.BOLD, 7, Ui.UNITS_pt));
    hfmTitle.add(title);

    vfmScreen.add(hfmTitle);    
    currScreen = UiApplication.getUiApplication().getActiveScreen();

    vectorData = new Vector();
    numData = 0;

    refresh=true;       
    getData RunnableGetData = new getData();
    PleaseWaitPopupScreen.showScreenAndWait(RunnableGetData, "Retrieving Data");                

    if (_stop)
    {
        numData = vectorData.size();            
        showHeaders();
    }

    add(vfmScreen);
}

public void fieldChanged(Field field, int context) {
    // TODO Auto-generated method stub      
}

class getData implements Runnable, Stoppable
{       
    public void run()
    {   
        vectorData.addElement(new data("data 1, 1", "data 1, 2", "data 1, 3", "data 1, 4", "data 1, 5", "data 1, 6", "data 1, 7", "data 1, 8", "data 1, 9"));
        vectorData.addElement(new data("data 2, 1", "data 2, 2", "data 2, 3", "data 2, 4", "data 2, 5", "data 2, 6", "data 2, 7", "data 2, 8", "data 2, 9"));
        vectorData.addElement(new data("data 3, 1", "data 3, 2", "data 3, 3", "data 3, 4", "data 3, 5", "data 3, 6", "data 3, 7", "data 3, 8", "data 3, 9"));
        vectorData.addElement(new data("data 4, 1", "data 4, 2", "data 4, 3", "data 4, 4", "data 4, 5", "data 4, 6", "data 4, 7", "data 4, 8", "data 4, 9"));
        vectorData.addElement(new data("data 5, 1", "data 5, 2", "data 5, 3", "data 5, 4", "data 5, 5", "data 5, 6", "data 5, 7", "data 5, 8", "data 5, 9"));
        vectorData.addElement(new data("data 6, 1", "data 6, 2", "data 6, 3", "data 6, 4", "data 6, 5", "data 6, 6", "data 6, 7", "data 6, 8", "data 6, 9"));
        vectorData.addElement(new data("data 7, 1", "data 7, 2", "data 7, 3", "data 7, 4", "data 7, 5", "data 7, 6", "data 7, 7", "data 7, 8", "data 7, 9"));
        vectorData.addElement(new data("data 8, 1", "data 8, 2", "data 8, 3", "data 8, 4", "data 8, 5", "data 8, 6", "data 8, 7", "data 8, 8", "data 8, 9"));

        final Stoppable ourProcessing = this;
        UiApplication.getUiApplication().invokeLater(new Runnable() {
            public void run() { 

                numData = vectorData.size();

                showHeaders();
                showData();
                refresh=false;

                if (numData > 0)
                {
                    tableList = new TableList(vectorData);
                    vfmTable.add(tableList);
                    tableList.setFocus();
                }
                else
                    tableList = null; 
            }
        });
    }

    public boolean stop() {
        // TODO Auto-generated method stub
        _stop = true;
        UiApplication.getUiApplication().popScreen(UiApplication.getUiApplication().getActiveScreen());
        return false;
    }

    public boolean isStopped() {
        // TODO Auto-generated method stub
        return _stop;
    }
}   

private void showHeaders()
{   
    hfmTableTitle = new HorizontalFieldManager(HorizontalFieldManager.USE_ALL_WIDTH | HorizontalFieldManager.NO_HORIZONTAL_SCROLL  | HorizontalFieldManager.NO_VERTICAL_SCROLL | HorizontalFieldManager.NO_SCROLL_RESET) {
        protected void sublayout( int maxWidth, int maxHeight)
        {
            int width = Display.getWidth();
            int height = subHeight+5;
            super.sublayout( width, height);
            super.setBackground(BackgroundFactory.createSolidBackground(Color.SILVER));
            setExtent( width, height);
        }
    };
    lblTableTitle = new LabelField("" + vectorData.size() + " rows", LabelField.USE_ALL_WIDTH | DrawStyle.HCENTER | DrawStyle.VCENTER);
    lblTableTitle.setPadding(2,2,2,2);
    lblTableTitle.setFont(Font.getDefault().derive(Font.BOLD, 7, Ui.UNITS_pt));
    hfmTableTitle.add(lblTableTitle);
    vfmScreen.add(hfmTableTitle);
}

private void showData()
{
    Font fontLblTitle = Font.getDefault().derive(Font.BOLD, 7, Ui.UNITS_pt);
    String label01="", label02="", label03="", label04="", label05="", label06="", label07="", label08="", label09="";

    HorizontalFieldManager hfmTable = new HorizontalFieldManager(HorizontalFieldManager.HORIZONTAL_SCROLL | HorizontalFieldManager.HORIZONTAL_SCROLLBAR | HorizontalFieldManager.NO_SCROLL_RESET | HorizontalFieldManager.NON_FOCUSABLE) {

        protected void drawFocus(Graphics g, boolean on) {
            System.out.println("HFM drawFocus");
        }

           protected boolean navigationMovement(int dx, int dy, int status, int time) {
               HomeGrid.DebugMessage("HFM before Current H: " + this.getHorizontalScroll() + ",V:" + this.getVerticalScroll());
               super.navigationMovement(dx, dy, status, time);
               HomeGrid.DebugMessage("HFM after Current H: " + this.getHorizontalScroll() + ",V:" + this.getVerticalScroll());
               return false;
           }
    };
    vfmTable = new VerticalFieldManager(VerticalFieldManager.NO_HORIZONTAL_SCROLL | VerticalFieldManager.NO_HORIZONTAL_SCROLLBAR | VerticalFieldManager.NO_VERTICAL_SCROLL | VerticalFieldManager.NO_VERTICAL_SCROLLBAR | VerticalFieldManager.NO_SCROLL_RESET | VerticalFieldManager.NON_FOCUSABLE)
    {
           protected void sublayout( int maxWidth, int maxHeight )
           {
               //set your width
               int width = widthField01 + widthField02 + widthField03 + widthField04 + widthField05 + widthField06 + widthField07 + widthField08 + widthField09;
               //set your height
               int height = (vectorData.size() + 1) * subHeight;

               super.sublayout( width, height);
               setExtent( width, height);
           }

           protected boolean navigationMovement(int dx, int dy, int status, int time) {
               HomeGrid.DebugMessage("VFM before Current H: " + this.getHorizontalScroll() + ",V:" + this.getVerticalScroll());
               super.navigationMovement(dx, dy, status, time);
               HomeGrid.DebugMessage("VFM after Current H: " + this.getHorizontalScroll() + ",V:" + this.getVerticalScroll());
               return false;
           }
    };
    vfmTable.setPadding(0,0,0,0);       

    TableLayoutManager tblTableRows;

    label01 = "   #";
    label02 = "Column 1";
    label03 = "Column 2";
    label04 = "Column 3";
    label05 = "Column 4";
    label06 = "Column 5";
    label07 = "Column 6";
    label08 = "Column 7";
    label09 = "Column 8";

    tblTableRows = new TableLayoutManager(new int[] { TableLayoutManager.FIXED_WIDTH, TableLayoutManager.FIXED_WIDTH, TableLayoutManager.FIXED_WIDTH,
                                                      TableLayoutManager.FIXED_WIDTH, TableLayoutManager.FIXED_WIDTH, TableLayoutManager.FIXED_WIDTH,
                                                      TableLayoutManager.FIXED_WIDTH, TableLayoutManager.FIXED_WIDTH, TableLayoutManager.FIXED_WIDTH },
                                          new int[] { widthField01, widthField02, widthField03, widthField04, widthField05, widthField06, widthField07, widthField08, widthField09 },
                                          0,
                                          Manager.NO_HORIZONTAL_SCROLL | Manager.NO_VERTICAL_SCROLL | Manager.NO_SCROLL_RESET);


    lblField01 = new LabelField(label01, LabelField.HCENTER | LabelField.FIELD_VCENTER) {
        protected void layout( int maxWidth, int maxHeight)
        {
            int width = widthField01;
            int height = subHeight;
            super.layout( width, height);
            super.setBackground(BackgroundFactory.createSolidBackground(Color.GRAY));
            setExtent( width, height);
        }
    };
    lblField01.setFont(fontLblTitle);
    tblTableRows.add(lblField01);   

    lblField02 = new LabelField(label02, LabelField.HCENTER | LabelField.FIELD_VCENTER) {
        protected void layout( int maxWidth, int maxHeight)
        {
            int width = widthField02;
            int height = subHeight;
            super.layout( width, height);
            super.setBackground(BackgroundFactory.createSolidBackground(Color.GRAY));
            setExtent( width, height);
        }
    };
    lblField02.setFont(fontLblTitle);
    tblTableRows.add(lblField02);   

    lblField03 = new LabelField(label03, LabelField.HCENTER | LabelField.FIELD_VCENTER) {
        protected void layout( int maxWidth, int maxHeight)
        {
            int width = widthField03;
            int height = subHeight;
            super.layout( width, height);
            super.setBackground(BackgroundFactory.createSolidBackground(Color.GRAY));
            setExtent( width, height);
        }
    };
    lblField03.setFont(fontLblTitle);
    tblTableRows.add(lblField03);           

    lblField04 = new LabelField(label04, LabelField.HCENTER | LabelField.FIELD_VCENTER) {
        protected void layout( int maxWidth, int maxHeight)
        {
            int width = widthField04;
            int height = subHeight;
            super.layout( width, height);
            super.setBackground(BackgroundFactory.createSolidBackground(Color.GRAY));
            setExtent( width, height);
        }
    };
    lblField04.setFont(fontLblTitle);
    tblTableRows.add(lblField04);       

    lblField05 = new LabelField(label05, LabelField.HCENTER | LabelField.FIELD_VCENTER) {
        protected void layout( int maxWidth, int maxHeight)
        {
            int width = widthField05;
            int height = subHeight;
            super.layout( width, height);
            super.setBackground(BackgroundFactory.createSolidBackground(Color.GRAY));
            setExtent( width, height);
        }
    };
    lblField05.setFont(fontLblTitle);
    tblTableRows.add(lblField05);           

    lblField06 = new LabelField(label06, LabelField.HCENTER | LabelField.FIELD_VCENTER) {
        protected void layout( int maxWidth, int maxHeight)
        {
            int width = widthField06;
            int height = subHeight;
            super.layout( width, height);
            super.setBackground(BackgroundFactory.createSolidBackground(Color.GRAY));
            setExtent( width, height);
        }
    };
    lblField06.setFont(fontLblTitle);
    tblTableRows.add(lblField06);           

    lblField07 = new LabelField(label07, LabelField.HCENTER | LabelField.FIELD_VCENTER) {
        protected void layout( int maxWidth, int maxHeight)
        {
            int width = widthField07;
            int height = subHeight;
            super.layout( width, height);
            super.setBackground(BackgroundFactory.createSolidBackground(Color.GRAY));
            setExtent( width, height);
        }
    };
    lblField07.setFont(fontLblTitle);
    tblTableRows.add(lblField07);           

    lblField08 = new LabelField(label08, LabelField.HCENTER | LabelField.FIELD_VCENTER) {
        protected void layout( int maxWidth, int maxHeight)
        {
            int width = widthField08;
            int height = subHeight;
            super.layout( width, height);
            super.setBackground(BackgroundFactory.createSolidBackground(Color.GRAY));
            setExtent( width, height);
        }
    };
    lblField08.setFont(fontLblTitle);
    tblTableRows.add(lblField08);           

    lblField09 = new LabelField(label09, LabelField.HCENTER | LabelField.FIELD_VCENTER) {
        protected void layout( int maxWidth, int maxHeight)
        {
            int width = widthField09;
            int height = subHeight;
            super.layout( width, height);
            super.setBackground(BackgroundFactory.createSolidBackground(Color.GRAY));
            setExtent( width, height);
        }
    };
    lblField09.setFont(fontLblTitle);
    tblTableRows.add(lblField09);

    vfmTable.add(tblTableRows);
    hfmTable.add(vfmTable);
    vfmScreen.add(hfmTable);        
}

public static class data {
    // In this example, to save accessors, the names are public
    public String datafield01=null, datafield02=null, datafield03=null, datafield04=null, datafield05=null, datafield06=null, datafield07=null, datafield08=null, datafield09=null;

    public data(String field1, String field2, String field3, String field4, String field5, String field6, String field7, String field8, String field9) 
    {
        datafield01 = field1;
        datafield02 = field2;
        datafield03 = field3;
        datafield04 = field4;
        datafield05 = field5;
        datafield06 = field6;
        datafield07 = field7;
        datafield08 = field8;
    }
}
}

现在我的ListField:

package ListFieldObjects;

import java.util.Vector;

import net.rim.device.api.system.Display;
import net.rim.device.api.ui.DrawStyle;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.Font;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.Manager;
import net.rim.device.api.ui.Ui;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.component.ListField;
import net.rim.device.api.ui.component.ListFieldCallback;
import Main.HomeGrid;
import Screens.TableScreen.data;

public class TableList extends ListField implements ListFieldCallback {

private Vector rows;
Vector vectorData;
TableRowManager row;
String optionType;
int subHeight = 0;
Font fontTable;
int widthField01=65, widthField02=150, widthField03=150, widthField04=150, widthField05=150, widthField06=150, widthField07=150, widthField08=150, widthField09=150, widthField10=150, widthField11=150, widthField12=150;

public TableList(Vector v) {
    super(0, ListField.USE_ALL_WIDTH | ListField.FOCUSABLE);

    switch (Display.getWidth()) {
        case 640:
            fontTable = Font.getDefault().derive(Font.SANS_SERIF_STYLE, 5, Ui.UNITS_pt);
            subHeight = 40;
            break;
        default:
            fontTable = Font.getDefault().derive(Font.SANS_SERIF_STYLE, 6, Ui.UNITS_pt);
            subHeight = 30;
            break;
    };

    setRowHeight(subHeight);
    setCallback(this);

    rows = new Vector();        
    vectorData = v;

    for (int i=0;i<vectorData.size();i++)
    {
        String field1=null, field2=null, field3=null, field4=null, field5=null, field6=null, field7=null, field8=null, field9=null;

        data d = (data) vectorData.elementAt(i);
        if (d.equals(null))
            continue;

        field1  = ""+(i+1);
        field2  = d.datafield01;
        field3  = d.datafield02;
        field4  = d.datafield03;
        field5  = d.datafield04;
        field6  = d.datafield05;
        field7  = d.datafield06;
        field8  = d.datafield07;
        field9  = d.datafield08;

        row = new TableRowManager();
        if (!field1.equals(null))
        {
            LabelField lblField1 = new LabelField(field1, LabelField.USE_ALL_WIDTH | DrawStyle.HCENTER | LabelField.FOCUSABLE);
            lblField1.setFont(fontTable);
            row.add(lblField1);
        }
        if (!field2.equals(null))
        {
            LabelField lblField2 = new LabelField(field2, LabelField.HCENTER | LabelField.FIELD_VCENTER | LabelField.FOCUSABLE);
            lblField2.setFont(fontTable);
            row.add(lblField2);
        }
        if (!field3.equals(null))
        {   
            LabelField lblField3 = new LabelField(field3, LabelField.HCENTER | LabelField.FIELD_VCENTER | LabelField.FOCUSABLE);
            lblField3.setFont(fontTable);
            row.add(lblField3);         
        }
        if (!field4.equals(null))
        {   
            LabelField lblField4 = new LabelField(field4, LabelField.HCENTER | LabelField.FIELD_VCENTER | LabelField.FOCUSABLE);
            lblField4.setFont(fontTable);
            row.add(lblField4);         
        }
        if (!field5.equals(null))
        {   
            LabelField lblField5 = new LabelField(field5, LabelField.HCENTER | LabelField.FIELD_VCENTER | LabelField.FOCUSABLE);
            lblField5.setFont(fontTable);
            row.add(lblField5);         
        }
        if (!field6.equals(null))
        {   
            LabelField lblField6 = new LabelField(field6, LabelField.HCENTER | LabelField.FIELD_VCENTER | LabelField.FOCUSABLE);
            lblField6.setFont(fontTable);
            row.add(lblField6);         
        }
        if (!field7.equals(null))
        {   
            LabelField lblField7 = new LabelField(field7, LabelField.HCENTER | LabelField.FIELD_VCENTER | LabelField.FOCUSABLE);
            lblField7.setFont(fontTable);
            row.add(lblField7);         
        }
        if (!field8.equals(null))
        {   
            LabelField lblField8 = new LabelField(field8, LabelField.HCENTER | LabelField.FIELD_VCENTER | LabelField.FOCUSABLE);
            lblField8.setFont(fontTable);
            row.add(lblField8);         
        }
        if (!field9.equals(null))
        {   
            LabelField lblField9 = new LabelField(field9, LabelField.HCENTER | LabelField.FIELD_VCENTER | LabelField.FOCUSABLE);
            lblField9.setFont(fontTable);
            row.add(lblField9);         
        }
        rows.addElement(row);
    }

    setSize(rows.size());
}

// ListFieldCallback Implementation
public void drawListRow(ListField listField, Graphics g, int index, int y, int width) {
    HomeGrid.DebugMessage("drawListRow; index="+index+"; y="+y+"; width="+width);
    TableList list = (TableList) listField;
    TableRowManager rowManager = (TableRowManager) list.rows.elementAt(index);
    int w = widthField01 + widthField02 + widthField03 + widthField04 + widthField05 + widthField06 + widthField07 + widthField08 + widthField09;
    rowManager.drawRow(g, 0, y, w, subHeight);
}

private class TableRowManager extends Manager {
    public TableRowManager() {
        super(0);
    }

    // Causes the fields within this row manager to be layed out then
    // painted.
    public void drawRow(Graphics g, int x, int y, int width, int height) {
        // Arrange the cell fields within this row manager.
        layout(width, height);

        // Place this row manager within its enclosing list.
        setPosition(x, y);

        // Apply a translating/clipping transformation to the graphics
        // context so that this row paints in the right area.
        g.pushRegion(getExtent());

        // Paint this manager's controlled fields.
        subpaint(g);

        g.setColor(0x00CACACA);
        g.drawLine(0, 0, getPreferredWidth(), 0);

        // Restore the graphics context.
        g.popContext();
    }

    // Arranges this manager's controlled fields from left to right within
    // the enclosing table's columns.
    protected void sublayout(int width, int height) {
        // set the size and position of each field.
        Field field;
        int xVal=1, yVal=3, fieldWidth=0;

        field = getField(0);
        if (!field.equals(null))
        {   
            fieldWidth = widthField01;
            layoutChild(field, fieldWidth, subHeight);
            setPositionChild(field, xVal, yVal);
            xVal = xVal + fieldWidth;
        }

        // start with the Bitmap Field of the priority icon
        field = getField(1);
        if (!field.equals(null))
        {   
            fieldWidth = widthField02;
            layoutChild(field, fieldWidth, subHeight);
            setPositionChild(field, xVal, yVal);
            xVal = xVal + fieldWidth;
        }

        // set the list name label field
        field = getField(2);
        if (!field.equals(null))
        {   
            fieldWidth = widthField03;
            layoutChild(field, fieldWidth, subHeight);
            setPositionChild(field, xVal, yVal);
            xVal = xVal + fieldWidth;                   
        }

        // set the list name label field
        field = getField(3);
        if (!field.equals(null))
        {   
            fieldWidth = widthField04;
            layoutChild(field, fieldWidth, subHeight);
            setPositionChild(field, xVal, yVal);
            xVal = xVal + fieldWidth;                   
        }

        // set the list name label field
        field = getField(4);
        if (!field.equals(null))
        {   
            fieldWidth = widthField05;
            layoutChild(field, fieldWidth, subHeight);
            setPositionChild(field, xVal, yVal);
            xVal = xVal + fieldWidth;                   
        }

        // set the list name label field
        field = getField(5);
        if (!field.equals(null))
        {   
            fieldWidth = widthField06;
            layoutChild(field, fieldWidth, subHeight);
            setPositionChild(field, xVal, yVal);
            xVal = xVal + fieldWidth;                   
        }

        // set the list name label field - Product
        field = getField(6);
        if (!field.equals(null))
        {   
            fieldWidth = widthField07;
            layoutChild(field, fieldWidth, subHeight);
            setPositionChild(field, xVal, yVal);    
            xVal = xVal + fieldWidth;               
        }

        // set the list name label field
        field = getField(7);
        if (!field.equals(null))
        {       
            fieldWidth = widthField08;
            layoutChild(field, fieldWidth, subHeight);
            setPositionChild(field, xVal, yVal);
            xVal = xVal + fieldWidth;               
        }

        // set the list name label field
        field = getField(8);
        if (!field.equals(null))
        {   
            fieldWidth = widthField09;
            layoutChild(field, fieldWidth, subHeight);
            setPositionChild(field, xVal, yVal);
            xVal = xVal + fieldWidth;                   
        }

        setExtent(xVal, subHeight);
    }

       protected boolean navigationMovement(int dx, int dy, int status, int time) {
           HomeGrid.DebugMessage("TRM before Current H: " + this.getHorizontalScroll() + ",V:" + this.getVerticalScroll());
           super.navigationMovement(dx, dy, status, time);
           HomeGrid.DebugMessage("TRM after Current H: " + this.getHorizontalScroll() + ",V:" + this.getVerticalScroll());
           return false;
       }

    // The preferred width of a row is defined by the list renderer.
    public int getPreferredWidth() {
        return widthField01 + widthField02 + widthField03 + widthField04 + widthField05 + widthField06 + widthField07 + widthField08 + widthField09;
    }

    // The preferred height of a row is the "row height" as defined in the
    // enclosing list.
    public int getPreferredHeight() {
        return getRowHeight();
    }
}

public Object get(ListField listField, int index) {
    return null;
}

public int getPreferredWidth(ListField listField) {
    return Display.getWidth();
}

public int indexOfList(ListField listField, String prefix, int start) {
    return 0;
}

protected boolean trackwheelClick(int status, int time)
{
    final int index = getSelectedIndex();

    return true;
}
}

亲切的问候,

标记

0 个答案:

没有答案