BlackBerry Storm - 焦点不在可滚动列表字段后添加的可聚焦字段上

发布于 2024-08-24 18:23:50 字数 574 浏览 5 评论 0原文

searchlist = new FileList(list_vector,ind,j);//a custom list field
searchlist.setRowHeight(40);
searchListManager = new VerticalFieldManager(
    Manager.VERTICAL_SCROLL |Manager.VERTICAL_SCROLLBAR)

searchListManager.add(searchlist);  
objManager.add(searchListManager);
HomeScreen1.this.add(header_manager);
HomeScreen1.this.add(objManager);   

//after few lines of code
 button_manager.add(Previous);
 button_manager.add(Next);
 objManager.add(button_manager); 

现在我的问题是,当我滚动列表字段时,下一个 n 前一个不可见 但是当我按向上和向下键时,他们只能看到

要做什么????????????

searchlist = new FileList(list_vector,ind,j);//a custom list field
searchlist.setRowHeight(40);
searchListManager = new VerticalFieldManager(
    Manager.VERTICAL_SCROLL |Manager.VERTICAL_SCROLLBAR)

searchListManager.add(searchlist);  
objManager.add(searchListManager);
HomeScreen1.this.add(header_manager);
HomeScreen1.this.add(objManager);   

//after few lines of code
 button_manager.add(Previous);
 button_manager.add(Next);
 objManager.add(button_manager); 

now my problem is when i scroll over the list field then next n previous are not visible
but when i press key up n down then they get only visible

what to do???????????

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

白况 2024-08-31 18:23:50

尝试将 searchListManager 实现为具有固定大小的可滚动 VerticalManager (显示高度 - 标题管理器高度 - 按钮管理器高度)

更新 尝试代码:

class Scr extends MainScreen implements ListFieldCallback {
    int DISPLAY_WIDTH = Display.getWidth();
    int DISPLAY_HEIGHT = Display.getHeight();
    Vector mItems = new Vector();
    ListField mListField = new ListField();
    SizedVFM mListManager = new SizedVFM(DISPLAY_WIDTH, DISPLAY_HEIGHT - 50);

    ButtonField mPrevButtonField = new ButtonField("Previous",
            ButtonField.CONSUME_CLICK);
    ButtonField mNextButtonField = new ButtonField("Next",
            ButtonField.CONSUME_CLICK);

    HorizontalFieldManager mButtonsManager = new HorizontalFieldManager(
            FIELD_HCENTER);

    public Scr() {
        for (int i = 1; i < 31; i++) {
            mItems.addElement("item " + String.valueOf(i));
        }

        mListField.setCallback(this);
        mListField.setSize(30);
        add(mListManager);
        mListManager.add(mListField);

        mPrevButtonField.setChangeListener(new FieldChangeListener() {
            public void fieldChanged(Field field, int context) {
                Dialog.inform("Previouse pressed");
            }
        });

        mNextButtonField.setChangeListener(new FieldChangeListener() {
            public void fieldChanged(Field field, int context) {
                Dialog.inform("Next pressed");
            }
        });

        mButtonsManager.add(mPrevButtonField);
        mButtonsManager.add(mNextButtonField);
        add(mButtonsManager);
    }

    public void drawListRow(ListField field, Graphics g, int i, int y, int w) {
        // Draw the text.
        String text = (String) get(field, i);
        g.drawText(text, 0, y, 0, w);
    }

    public Object get(ListField listField, int index) {
        return mItems.elementAt(index);
    }

    public int getPreferredWidth(ListField listField) {
        return DISPLAY_WIDTH;
    }

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

class SizedVFM extends VerticalFieldManager {
    int mWidth;
    int mHeight;

    public SizedVFM(int width, int height) {
        super(VERTICAL_SCROLL | VERTICAL_SCROLLBAR);
        mWidth = width;
        mHeight = height;
    }

    public int getPreferredHeight() {
        return mHeight;
    }

    public int getPreferredWidth() {
        return mWidth;
    }

    public void setHeight(int height) {
        mHeight = height;
    }

    protected void sublayout(int maxWidth, int maxHeight) {
        super.sublayout(maxWidth, maxHeight);
        setExtent(getPreferredWidth(), getPreferredHeight());
    }
}

结果应该是这样的:
替代文本 http://img215.imageshack.us/img215/1402/9530list.jpg< /a>

Try to implement searchListManager as a scrollable VerticalManager with fixed size (Display height - header manager height - button manager height)

UPDATE Code to try:

class Scr extends MainScreen implements ListFieldCallback {
    int DISPLAY_WIDTH = Display.getWidth();
    int DISPLAY_HEIGHT = Display.getHeight();
    Vector mItems = new Vector();
    ListField mListField = new ListField();
    SizedVFM mListManager = new SizedVFM(DISPLAY_WIDTH, DISPLAY_HEIGHT - 50);

    ButtonField mPrevButtonField = new ButtonField("Previous",
            ButtonField.CONSUME_CLICK);
    ButtonField mNextButtonField = new ButtonField("Next",
            ButtonField.CONSUME_CLICK);

    HorizontalFieldManager mButtonsManager = new HorizontalFieldManager(
            FIELD_HCENTER);

    public Scr() {
        for (int i = 1; i < 31; i++) {
            mItems.addElement("item " + String.valueOf(i));
        }

        mListField.setCallback(this);
        mListField.setSize(30);
        add(mListManager);
        mListManager.add(mListField);

        mPrevButtonField.setChangeListener(new FieldChangeListener() {
            public void fieldChanged(Field field, int context) {
                Dialog.inform("Previouse pressed");
            }
        });

        mNextButtonField.setChangeListener(new FieldChangeListener() {
            public void fieldChanged(Field field, int context) {
                Dialog.inform("Next pressed");
            }
        });

        mButtonsManager.add(mPrevButtonField);
        mButtonsManager.add(mNextButtonField);
        add(mButtonsManager);
    }

    public void drawListRow(ListField field, Graphics g, int i, int y, int w) {
        // Draw the text.
        String text = (String) get(field, i);
        g.drawText(text, 0, y, 0, w);
    }

    public Object get(ListField listField, int index) {
        return mItems.elementAt(index);
    }

    public int getPreferredWidth(ListField listField) {
        return DISPLAY_WIDTH;
    }

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

class SizedVFM extends VerticalFieldManager {
    int mWidth;
    int mHeight;

    public SizedVFM(int width, int height) {
        super(VERTICAL_SCROLL | VERTICAL_SCROLLBAR);
        mWidth = width;
        mHeight = height;
    }

    public int getPreferredHeight() {
        return mHeight;
    }

    public int getPreferredWidth() {
        return mWidth;
    }

    public void setHeight(int height) {
        mHeight = height;
    }

    protected void sublayout(int maxWidth, int maxHeight) {
        super.sublayout(maxWidth, maxHeight);
        setExtent(getPreferredWidth(), getPreferredHeight());
    }
}

And the result should be like that:
alt text http://img215.imageshack.us/img215/1402/9530list.jpg

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文