BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 10-22-2009, 08:31 AM   #1 (permalink)
New Member
 
Join Date: Sep 2009
Model: 7100t
PIN: N/A
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
Code:
            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?
Offline  
Old 10-23-2009, 02:59 AM   #2 (permalink)
Knows Where the Search Button Is
 
Join Date: Mar 2009
Model: 8100
PIN: N/A
Carrier: Airtel
Posts: 16
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.
Offline  
Old 10-26-2009, 07: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 07:54 AM.
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





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