gpt4 book ai didi

具有固定大小的黑莓 VerticalFieldManager : Scroll issue

转载 作者:行者123 更新时间:2023-12-02 19:59:54 26 4
gpt4 key购买 nike

我试图拥有一个带有修复标题(带有一些字段的管理器)和可滚动内容(自定义字段列表)的全屏用户界面。这个想法是模拟一种可滚动列表。

为此,我制作了一个自定义 VerticalFieldManager,它接受 maxHeight(屏幕高度 - 标题高度)。

我遇到了以下问题:

  • 滚动箭头(永远)不显示
  • 在 OS 4.7 (Storm) 上,我可以向下滚动到最后一项,直到屏幕上除了标题之外没有任何内容。

我的代码需要使用 JDE 4.2.1 和 4.7 进行编译并在 Pearl 和 Storm 上运行。 (最坏的情况下我可以有这个类的两个版本)

我怀疑这两个问题是相关的。我可能做错了什么。我查看了一些示例/论坛,总是找到类似的解决方案/代码。你们能告诉我我做错了什么吗?

/**
* 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);
}


}

欢迎任何帮助。

最佳答案

所以,

我为 STORM 上的“空白可滚动区域”问题提供了此解决方法它很丑陋,并且不允许自定义 ScrollChangeListener,但它可以在 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);
}
}

我仍在寻找滚动箭头问题的解决方案......如果有人有想法...

关于具有固定大小的黑莓 VerticalFieldManager : Scroll issue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1660230/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com