BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 08-29-2011, 08:24 AM   #1 (permalink)
New Member
 
Join Date: Aug 2011
Model: 7100T
PIN: N/A
Carrier: Az
Posts: 4
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Display problem overriding ButtonField

Please Login to Remove!

Hello,

I have a problem overriding ButtonField. As the Field.USE_ALL_WIDTH flag doesn't work for ButtonField, I have to extend it.

I just override the layout method like this :

protected void layout(int width, int height) {
setExtent(width, getPreferredHeight());
}

I have several buttons in a VerticalFieldManager. My first button displays correctly, but others are empty (good size, but no text). I have to click the buttons to make the text appear.

Am I missing something ? The problem comes from the layout method I guess, because it's the only method I override.

Thanks !

Edit : Tested on JDE 4.7.0 and 6.0.0, same behaviour

Last edited by laurre : 08-29-2011 at 09:23 AM.
Offline  
Old 08-29-2011, 10:00 AM   #2 (permalink)
BlackBerry Extraordinaire
 
Join Date: Jan 2006
Model: LEZ10
OS: 10.0.10
Carrier: Rogers CA
Posts: 1,704
Post Thanks: 20
Thanked 77 Times in 68 Posts
Default Re: Display problem overriding ButtonField

I'm not on a machine where I can look at my layout code at the moment, but IIRC unless the Manager does something about it, layout is called with huge numbers (infinity for practical perposes) for width and height. The text then gets centred between 0 and the huge number. Use the debugger to see what the value for width is to confirm this, but what you probably want to use is Device.getWidth().
__________________
My other Blackberry is a PlayBook.
Offline  
Old 08-29-2011, 10:17 AM   #3 (permalink)
New Member
 
Join Date: Aug 2011
Model: 7100T
PIN: N/A
Carrier: Az
Posts: 4
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Re: Display problem overriding ButtonField

I have already debugged : the value for width is 324 (the display's width is 360), and for height 1073741743, but in my case I ignore this last value, so it should be ok...

getPreferredHeight() returns 20 in my case. So the buttons should display correctly, I don't get it !

Last edited by laurre : 08-29-2011 at 10:20 AM.
Offline  
Old 08-30-2011, 07:17 AM   #4 (permalink)
New Member
 
Join Date: Aug 2011
Model: 7100T
PIN: N/A
Carrier: Az
Posts: 4
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Re: Display problem overriding ButtonField

It seems that another thing is done in the super.layout() method. Seems to be an internal stuff, for text positioning I think.

The technique I have found, even if it is not the best one I guess :

- don't override layout
- override getPreferredHeight() and getPreferredWidth() :

Code:
public int getPreferredHeight() {
     if (isStyle(USE_ALL_HEIGHT)) {
          return Integer.MAX_VALUE;
     }
     return super.getPreferredHeight();
}

public int getPreferredWidth() {
     if (isStyle(USE_ALL_WIDTH)) {
          return Integer.MAX_VALUE;
     }
     return super.getPreferredWidth();
}
I hope this works in any situations. I know it is not very very clean, if you have a better idea...
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads for: Display problem overriding ButtonField
Thread Thread Starter Forum Replies Last Post
BB Pearl 8120 calendar display problem martin808 General BlackBerry Discussion 0 01-03-2008 06:53 AM
problem with display screen inath General 8100 Series Discussion - Pearl 1 11-18-2007 07:56 AM
Display problem in Desktop Manager crenaud76 General Legacy Device Discussion 1 10-17-2007 01:20 AM
Am I seeing things or is this a display problem? arazu General Legacy Device Discussion 6 08-05-2007 09:48 PM
Display problem Nomads Developer Forum 1 06-25-2007 06:28 AM





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.