如何捕捉listfield滚动到底在黑莓7 [英] how to capture listfield scroll to bottom in blackberry 7

查看:183
本文介绍了如何捕捉listfield滚动到底在黑莓7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有很多数据的listfield,起初我从加载服务器10的记录,我想捕获事件当滚动移动到谷底,我可以从服务器加载更多的记录。

I have a listfield with many data, at first i load 10 records from server, i want to capture the event when the scroll has moved to bottom, that i can load more records from server.

我实现ScrollChangeListener:

I implements ScrollChangeListener:

public class DataListScreen extends MainScreen implements ScrollChangeListener {
    public void scrollChanged(Manager manager, int newHorizontalScroll, int newVerticalScroll) {
        System.out.println(getVirtualHeight()); // 480
        System.out.println(getVisibleHeight()); // 480
        System.out.println(newVerticalScroll); // 0 - 1259
    }
}

但我知道如何让垂直滚动最大大小?

but i do know how to get vertical scroll max size?

任何想法?请帮我。

推荐答案

如果您使用的是 ListField ,并且正在通过扩展执行自定义绘制 ListFieldCallback ,那么你就可以检测到行集中的 drawListRow 方法中:

If you are using ListField, and you are performing custom painting by extending ListFieldCallback, then you can detect that a row is focused inside the drawListRow method:

    public void drawListRow(ListField lf, Graphics g, int index, int y, int x) {

        if (lf.isFocus() && lf.getSelectedIndex() == index) {
            //The selected row is bein repainted

            if(index == (lf.getSize() - 1)){
                //The last row is being focused
            }
        }

    }

然后,你可以要求在辅助线程的新元素。阻止的加载消息GUI。

Then you can request new elements in a worker thread. Block the GUI with a loading message.

这是一个基本的解决问题的办法。在一个真正的亲应用,您需要preemtively请求新的批次的元素,当用户将要到达列表的末尾(选择的列表的行=大小 - 即适合在屏幕的行数)。这样,它可以向下滚动无需等待。你不得不处理超过同一批次失败的请求以及多个用户发起的请求。

This is a basic solution to the problem. In a real pro app, you'd preemtively request a new batch of elements when the user is about to reach the end of the list (selected row = size of the list - number of rows that fit in the screen). This way it can scroll down without waiting. You'd have to handle failed requests as well as multiple user initiated requests over the same batch.

这篇关于如何捕捉listfield滚动到底在黑莓7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆