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
Developer
sowjanya1919
Posts: 109
Registered: ‎08-21-2012
My Device: Blackberry curve

BrowserField Width issue

I want to specifiy the width for my browserfield but not the height ...Can anyone tell me how to set the width

for the browserfield where the height is dynamic.Height should not be static.

Developer
kanaksony
Posts: 571
Registered: ‎04-11-2009
My Device: BB 10 Dev Alpha

Re: BrowserField Width issue

Hi, 

 

You can sublayout the manager in which your browserfield is added.

 

VerticalFieldManager _vfmBrowser = new VerticalFieldManager(){
	protected void sublayout(int maxWidth, int maxHeight) {
		super.sublayout(maxWidth, getPreferredHeight());
		setExtent(maxWidth, getPreferredHeight());
	}
	public int getPreferredHeight() {
		return dynamic_height_value;
	}
};

_vfmBrowser.add(_browserField);
Regards,
Kanak Sony
------------------------------------------------------------------------------------------
http://dodevelopnshare.wordpress.com/ | http://www.linkedin.com/profile/view?id=188131481&trk=tab_pro
Developer
sowjanya1919
Posts: 109
Registered: ‎08-21-2012
My Device: Blackberry curve

Re: BrowserField Width issue

the" dynamic_height_value" variable again has to declare with some value....this value i will not come to know...as some time only 5lines are coming in browserfield and some time 100lines....Know tell me what to do...i finally want the height should not be specified anywhere.
Developer
kanaksony
Posts: 571
Registered: ‎04-11-2009
My Device: BB 10 Dev Alpha

Re: BrowserField Width issue

There sould be no problem in declaring it by some default value, and do initialize it with your dynamic value..!!

Regards,
Kanak Sony
------------------------------------------------------------------------------------------
http://dodevelopnshare.wordpress.com/ | http://www.linkedin.com/profile/view?id=188131481&trk=tab_pro
Developer
sowjanya1919
Posts: 109
Registered: ‎08-21-2012
My Device: Blackberry curve

Re: BrowserField Width issue

how to know that dynamic value once the browser is loaded.

Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: BrowserField Width issue

Two things:

 

1) kanaksony's code restricts the height and not the width.  Here is a sublayout which is intended to restrict the width to at most 200 pixels:

 

protected void sublayout(int maxWidth, int maxHeight) {
  super.sublayout(Math.min(maxWidth, 200), maxHeight);
}

 

sublayout should always respect the values passed in - these are the maximum amount of screen estate that the Manager can use.

 

2) As a general rule, if you need to put a setExtent in your sublayout, then you should layout the children you  have yourself.

So this sublayout:

protected void sublayout(int maxWidth, int maxHeight) {
  super.sublayout(maxWidth, getPreferredHeight());
  setExtent(maxWidth, getPreferredHeight());
}

tells the Manager to restrict its height to a maximum of getPreferredHeight(), and then forces the Manager to use all the height.  But in the call to super.sublayout, the Manager will have decided where all the Fields go and how much space it really needs vertically and it may have used less.  This should be respected.  Forcing a size may confuse the issue. 

 

These are general points, and there are many curve balls related to Managers, most specifically around whether they are scrolling or not. 

 

But I think this will help answer the question in this case.

 

Hope this helps.