Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Trusted Contributor
NGeldenhuys
Posts: 176
Registered: ‎04-12-2012
My Device: Bold 9780 & Curve 8250
My Carrier: vodacom
Accepted Solution

HFM Not working Accordingly

Hey guys this piece of code works perfectly fine on the 8520, and on the 9780 it only displays one checkbox.I have Removed the padding and also added in "USE ALL WIDTH", the VFM works fine though, whats missing???

 

HorizontalFieldManager SharingManager=new HorizontalFieldManager();

public MyScreen(){

    CheckboxField FBCheckbox=new CheckboxField("", false,FOCUSABLE);
    CheckboxField TwitterCheckbox=new CheckboxField("",false,FOCUSABLE);
    CheckboxField LinkdInCheckbox=new CheckboxField("",false,FOCUSABLE);

 

    FBCheckbox.setPadding(0, 10, 0, 10);
    TwitterCheckbox.setPadding(0, 10, 0, 10);
    LinkdInCheckbox.setPadding(0, 10, 0, 10);

 

    SharingManager.add(FBCheckbox);

    SharingManager.add(new BitmapField(Bitmap.getBitmapResource("Share_Facebook.png")));
    SharingManager.add(TwitterCheckbox);
    SharingManager.add(new BitmapField(Bitmap.getBitmapResource("Share_Twitter.png")));
    SharingManager.add(LinkdInCheckbox);
    SharingManager.add(new BitmapField(Bitmap.getBitmapResource("Share_LinkedIn.png")));

 

    add(SharingManager);

}

Please use plain text.
Developer
simon_hain
Posts: 16,113
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: HFM Not working Accordingly

some fields want the full width by default, you have to take control and limit them.

use the style
http://www.blackberry.com/developers/docs/7.1.0api/net/rim/device/api/ui/component/CheckboxField.htm...
(or, if you are below 7.0, either overwrite getPreferredWidth or use a custom layout).
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Trusted Contributor
NGeldenhuys
Posts: 176
Registered: ‎04-12-2012
My Device: Bold 9780 & Curve 8250
My Carrier: vodacom

Re: HFM Not working Accordingly

Hi Simon

 

Thank you for the good advice, I am using 5.0.

 

I tried to over write the getPreferredWidth() ; but it made no difference. While I was researching this issue it seems to be a common problem. While I was testing I also noticed that the checkBoxFields were not causing the proble mut the BitmapFields were. I wanted to use the custom Layout Method, I tried and was unsuccessfull due to me not understanding how to use the method. 

 

I found a solution that seems to have done the trick :smileyhappy:

 

 Thank you for your help, i am sure that one day when I have enough experience as a developer a lot of your advice will help me out then.

 

GridFieldManager gfm = new GridFieldManager(1,6, Manager.HORIZONTAL_SCROLL | Manager.HORIZONTAL_SCROLLBAR | Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR);

final CheckboxField back1_1 = new CheckboxField("", false,FOCUSABLE);
final CheckboxField back1_2 = new CheckboxField("", false,FOCUSABLE);
final CheckboxField back1_3 = new CheckboxField("", false,FOCUSABLE);

gfm.add(new BitmapField(Bitmap.getBitmapResource("facebook.png")));
gfm.add(back1_1);

gfm.add(new BitmapField(Bitmap.getBitmapResource("twitter.png")));
gfm.add(back1_2);

gfm.add(new BitmapField(Bitmap.getBitmapResource("icon.png")));
gfm.add(back1_3);

add(gfm);

Please use plain text.
Developer
simon_hain
Posts: 16,113
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: HFM Not working Accordingly

yes, a gridfieldmanager avoids this issue. if you want to build complex UIs you will have to learn how to do a custom layout anyhow, the built-in managers are just too limited.

this should help, just in case you are interested:
http://supportforums.blackberry.com/t5/Java-Development/How-to-Extend-Manager/ta-p/446749
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.