BlackBerry Forums Support Community               

Closed Thread
LinkBack Thread Tools
Old 10-22-2009, 09:31 AM   #1 (permalink)
New Member
Join Date: Sep 2009
Model: 7100t
Carrier: o2
Posts: 5
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default set height LabelField

Please Login to Remove!

I have been searching for an example of how to set the height of a label field. I have read that you need to extend the class and override getPreferredHeight(). How would you do this? I have tried the following
            LabelField lbl_overview = new LabelField("Overview",LabelField.FIELD_HCENTER)
                public int getPreferredHeight(){
                    return 200;
Which is wrong, as all I am doing is returning a height. Does any one have a simple example?
Old 10-23-2009, 03:59 AM   #2 (permalink)
Knows Where the Search Button Is
Join Date: Mar 2009
Model: 8100
Carrier: Airtel
Posts: 16
Post Thanks: 0
Thanked 0 Times in 0 Posts

Hi Mabin,

You are doing right by overriding this method but you haven't told this label field to take your given height you have to use setExtent method to give your preferred height.
Old 10-26-2009, 08:51 AM   #3 (permalink)
Thumbs Must Hurt
Join Date: Mar 2007
Location: India
Model: 8100
Carrier: Airtel
Posts: 64
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default set height LabelField

try this

protected void layout(int width, int height){
super.layout(lblWidth, lblHeight);
setExtent(lblWidth, lblHeight);

lblWidth is width of the label
lblHeight is height of label

both are calculated..
Crazy for BlackBerry

Last edited by renuka_anil : 10-26-2009 at 08:54 AM.
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

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