Blackberry: VerticalFieldManager Child Element Not Receiving Focus
I have a VerticalFieldManger
which is used as container to display a custom news feed. The idea is an image (BitmapField
) and a title (LabelField
) are placed in the VerticalFieldManager
.
I have subclassed VerticalFieldManager
for some simple custom elements and their behviours, but I have not overridden any methods declared in the VerticalFieldManager
.
I would like the BitmapField
to respond to touch events and navigation clicks to as to open a web browser to display a desired web page. The issue is that the VerticalFieldManager
does not receive focus (I did not expect it to), nor do any of the child elements receive focus.
I have not subclassed BitmapField nor LabelField
Constructor for my subclassed VerticalFieldManager:
public NewsManagerView( boolean _isClickable, long _style ) {
super( _style );
this.setIsClickable( _isClickable ); // s开发者_StackOverflowets flag if this should respond to click events
this.init(); // initialize ivars
this.add( this.getTitle() ); // add child fields
this.add( this.getImgFld() );
this.add( this.getUrl() );
}
Which gets instantiated like this:
this.setNewsManager( new NewsManagerView(this.getIsConnected(), Field.USE_ALL_WIDTH) );
This is a known problem. I started a topic in BB support forum http://supportforums.blackberry.com/t5/Java-Development/Scroll-happening-but-Vertical-Field-Manager-Not-Moving/m-p/1214481
And the answer given was http://supportforums.blackberry.com/t5/Java-Development/My-scrollable-manager-is-not-scrolling/ta-p/445247
Sorry that is not a real answer but is the only workaround that's available for the moment
EDIT: In the BB forum a new post added says:
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.
VerticalFieldManager datavfm=new VerticalFieldManager(FOCUSABLE)
{
protected void paintBackground(Graphics graphics)
{
if(!isFocus())
{
graphics.setColor( 0xDDDDDD );
graphics.fillRoundRect( 0, 0, 318, 30, 18, 18);
graphics.setColor( 0x000000 );
graphics.drawRoundRect( 0, 0, 318, 30, 18, 18);
invalidate();
}
else
{
graphics.setColor( 0x005DE7 );
graphics.fillRoundRect( 0, 0, 318, 30, 18, 18);
graphics.setColor( 0xFFFFFF );
graphics.drawRoundRect( 0, 0, 318, 30, 18, 18);
graphics.setColor( 0xFFFFFF );
invalidate();
}
}
protected void sublayout(int maxWidth,int maxHeight)
{
super.sublayout(318, 30);
super.setExtent(318, 30);
}
protected boolean navigationClick(int status,int time)
{
GetPNRStatus(strPNRNumber);
return true;
}
protected boolean keyChar(char c, int status, int time)
{
if (c == Characters.ENTER)
{
GetPNRStatus(strPNRNumber);
}
return true;
}
};
精彩评论