黑莓VerticalFieldManager固定大小:滚动发行 [英] Blackberry VerticalFieldManager with fixed size : Scroll issue
问题描述
我想有一个固定头部(某些字段经理)和一个滚动的内容(自定义字段列表)全屏UI。这样做是为了模拟一种滚动列表的。
I'm trying to have a full screen UI with a fix header ( a manager with some fields) and a scrollable contents (a list of custom field). The idea is to emulate a kind of scrollable list.
有关这个我做了一个自定义的VerticalFieldManager是接受了maxHeight(屏幕高度 - 头部高度)。
For this I made a custom VerticalFieldManager that accept a maxHeight (the screen height - the header height).
我有以下问题:
- 滚动箭头不显示(永远)
- 在OS 4.7(暴风影音),我可以滚动比的最后一个项目,直至有我的屏幕,但头就没事。
我的code需要编译与JDE 4.2.1&安培; 4.7以及珍珠和风暴运行。 (在最坏的情况,我可以有两个版本,这个类的)
My code need to compile with the JDE 4.2.1 & 4.7 and to run on Pearl and Storm. (at worst I could have two version of this class)
我怀疑这两个问题是相关的。我可能做错事。我看了看几个例子/论坛,总能找到类似的解决方案/ code。
难道你们可以告诉我,我做错了什么?
I suspect the two problems are related. I probably do something wrong. I looked at a few example/forum and always found similar solution/code. Do you guys can tell me what I did wrong?
/**
* custom class, so we can set a max height (to keep the header visible)
*/
class myVerticalFieldManager extends VerticalFieldManager{
private int maxHeight = 0;
myVerticalFieldManager(int _maxHeight){
super(
//this provoc an "empty scrollable zone" on Storm
// but if you don't put it, on other OS, the vertical manager does not scroll at all.
Manager.VERTICAL_SCROLL
| Manager.VERTICAL_SCROLLBAR
);
maxHeight = _maxHeight;
}
protected void sublayout(int width, int height){
super.sublayout(width, getPreferredHeight());
setExtent(width, getPreferredHeight());
}
public int getPreferredWidth() {
return Graphics.getScreenWidth();
}
/**
* allow the manager to use all the given height. (vs auto Height)
*/
public boolean forceMaxHeight = false;
public int getPreferredHeight() {
if (forceMaxHeight) return maxHeight;
int m = super.getPreferredHeight();
if (m > maxHeight) m = maxHeight;
return m;
}
////////////////////////////////////////////////////////////////////////////
protected boolean isUpArrowShown(){
//TODO: does not seem to work (4.2.1 emulator & 4.5 device). (called with good return value but the arrows are not painted)
int i = getFieldWithFocusIndex();
//Trace("isUpArrowShown " + i);
return i > 0;
// note: algo not correct, cause the up arrow will be visible event when no field are hidden.
// but not so bad, so the user "know" that he can go up.
}
protected boolean isDownArrowShown(){
int i = getFieldWithFocusIndex();
return i < getFieldCount();
}
////////////////////////////////////////////////////////////////////////////
// note : since 4.6 you can use
// http://www.blackberry.com/developers/docs/4.6.0api/net/rim/device/api/ui/decor/Background.html
public int myBackgroundColor = 0xffffff;
protected void paint(Graphics g){
g.setBackgroundColor(myBackgroundColor);
// Clears the entire graphic area to the current background
g.clear();
super.paint(g);
}
}
任何帮助是值得欢迎的。
any helps is welcome.
推荐答案
因此,
我来到这个解决方法上STORM空滚动区的问题
它的丑陋,不允许自定义ScrollChangeListener,但它的工作对珍珠放大器;风暴
I came with this workaround for the "empty scrollable zone" problem on STORM it's ugly and doesn't allow a custom ScrollChangeListener, but it's working on Pearl & Storm
implements ScrollChangeListener
//in constructor:
setScrollListener(null);
setScrollListener(this);
private boolean MY_CHANGING_SCROLL = false;
public void scrollChanged(Manager manager, int newHorizontalScroll, int newVerticalScroll){
if (!MY_CHANGING_SCROLL){
MY_CHANGING_SCROLL = true;
myCheckVerticalScroll();
MY_CHANGING_SCROLL = false;
}
}
protected int myMaxVerticalScrollPosition(){
int vh = getVirtualHeight();
int h = getHeight();
if (vh < h ) return 0; // no scroll
return vh - h; // don't scroll lower than limit.
}
protected void invCheckVerticalScroll() {
int i = getVerticalScroll();
int m = myMaxVerticalScrollPosition();
if ( i > m){
i = m;
setVerticalScroll(i);
}
}
我还在寻找一个解决方案,以滚动箭头的问题...
如果有人有一个想法......
I'm still looking for a solution to the scroll arrows problem... If anybody got an idea...
这篇关于黑莓VerticalFieldManager固定大小:滚动发行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!