开发者

How to create focusable horizontal field manager in Blackberry

I need focusable horizontal field manager,for this i found some code in forums.

        hfm[i]=new HorizontalFieldManager(HorizontalFieldManager.FOCUSABLE)
        {
            protected void onFocus(int direction)
            {
                Background bg = BackgroundFactory.createLinearGradientBackground(0x00E2E2E2,0x00E2E2E2,0x00E2E2E2,0x00E2E2E2);
                setBackground(bg);
            }

开发者_如何学运维            protected void onUnfocus()
            {
                Background bg = BackgroundFactory.createLinearGradientBackground(0x00FFFFFF,0x00FFFFFF,0x00FFFFFF,0x00FFFFFF);
                setBackground(bg);
            }
        };
rtf[i]=new ExtendedLabel(list[i]);
hfm[i].add(rtf[i]);
add(hfm[i]);

But the it is not focusable,if it


You should also add this method to your new HorizontalFieldManager

public boolean isFocusable(){
    return true;
}

Remember though when you set a manager to be focusable in this way it must have a field within it that is focusable or else you will get a null exception when the screen tries to give your managae focus.


This is a known problem that happens to everyone at least one time. I started a topic in BB support forum:
Scroll happening but Vertical Field Manager Not Moving

And the answer given was the blackberry support forum article:
My scrollable manager is not scrolling

That is not a real answer but is the only workaround that's available for the moment

Another posible solution to this is:

A friend gave me the solution... you can put your manager into an horizontal manager and then you can just add an nullfield with a focusable behaviour, This will do the trick

You can try that.


You give focus to this.

rtf[i]=new ExtendedLabel(list[i]);

as....

rtf[i]=new ExtendedLabel(list[i],Field.Focusable);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜