BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 11-01-2009, 09:18 PM   #1 (permalink)
Thumbs Must Hurt
 
Join Date: Aug 2009
Model: Tour
PIN: N/A
Carrier: Verizon
Posts: 84
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Set Height of VerticalFieldManager

Please Login to Remove!

I need to have an Option Choice Field (drop downlist) above a VerticalFieldManager with another Option Choice Field below that. Because I will eventually need to have an additional field next to the ones I've listed (above and below the VFM), I'm putting them in a HorizontalFieldMaanager.

I want the VFM to scroll and to have both HFM's stay at the top and bottom of the screen.

I extended VFM and overwrote the getPreferredHeight method. But VFM still has a height of 0 (zero).

Code:
class VFN extends VerticalFieldManager{
	VFN(){
		super();
	}
	public int getPreferredWidth() {
	   return Display.getWidth();
	}
	   
	public int getPreferredHeight(){
		return _height;
	}
	public void setHeight(int h){
		_height = h;
	}
	private int _height;
}

class CashBoxApp extends UiApplication{
	public static void main(String[] args){
		CashBoxApp app = new CashBoxApp();
        app.enterEventDispatcher();	
	}
	CashBoxApp(){
		HorizontalFieldManager hfnTop = new HorizontalFieldManager();
		
		//VerticalFieldManager vfn = new VerticalFieldManager();
		VFN vfn= new VFN();
		HorizontalFieldManager hfnBottom = new HorizontalFieldManager();
		final MainScreen TxnListScreen = new MainScreen();

        TxnListScreen.setTitle("Cash Box");
        
        String[] AcctChoices={"Checking Personal","Savings","CC - CapOne"};
        hfnTop.add(new ObjectChoiceField("", AcctChoices,0));
        
     
        String[] BalChoices={"Ending Balance","Current Balance"};
        hfnBottom.add(new ObjectChoiceField("", BalChoices,0));
        
        vfn.setHeight(Display.getHeight()-hfnTop.getHeight()-hfnBottom.getHeight());
        TxnListScreen.add(hfnTop);
        TxnListScreen.add(vfn);
        TxnListScreen.add(hfnBottom);
        pushScreen(TxnListScreen);
	}		
}
__________________
Don

Handspring Visor -> Handspring Visor Deluxe -> Palm Treo 650 on VZW -> Palm Treo 700p on VZW -> Blackberry Tour 9360 on VZW
Offline  
Old 11-01-2009, 09:43 PM   #2 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

I think this is typical behavior of VFM - it takes the height required to accomodate it's managed field(s).
Offline  
Old 11-01-2009, 10:11 PM   #3 (permalink)
Thumbs Must Hurt
 
Join Date: Aug 2009
Model: Tour
PIN: N/A
Carrier: Verizon
Posts: 84
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

So how would I accomplish this task then? I want to have an hfm across the top of the screen, another across the bottom and the area between them allow for vertical scroll.
__________________
Don

Handspring Visor -> Handspring Visor Deluxe -> Palm Treo 650 on VZW -> Palm Treo 700p on VZW -> Blackberry Tour 9360 on VZW
Offline  
Old 11-03-2009, 04:08 PM   #4 (permalink)
Thumbs Must Hurt
 
Join Date: Aug 2009
Model: Tour
PIN: N/A
Carrier: Verizon
Posts: 84
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Anyone have any suggestions? I'm getting so frustrated with this--I've done lots of searches and it looks like others are doing what I'm trying to accomplish. But I'm having trouble doing it myself.
__________________
Don

Handspring Visor -> Handspring Visor Deluxe -> Palm Treo 650 on VZW -> Palm Treo 700p on VZW -> Blackberry Tour 9360 on VZW
Offline  
Old 11-03-2009, 04:22 PM   #5 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

Where are you adding a field to the vertical field manager? I don't understand what you are trying to accomplish, and neither does the system.

A Manager takes the height required to accomodate the fields contained therein. This Manager has no fields, hence no height.
Offline  
Old 11-03-2009, 07:18 PM   #6 (permalink)
Thumbs Must Hurt
 
Join Date: Aug 2009
Model: Tour
PIN: N/A
Carrier: Verizon
Posts: 84
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok I've made a lot of progress tonight. I found an example that I understood and now I'm able to set the height of the VFM. For anyone looking to do this, once I added the sublayout method shown below it to started working.

But I'm still having trouble figuring out what the required heights are for the HFMs above and below the VFM.

class VFN extends VerticalFieldManager{
VFN(){
super(VERTICAL_SCROLL|VERTICAL_SCROLLBAR|NO_HORIZO NTAL_SCROLL|USE_ALL_WIDTH);
}
protected void sublayout(int width, int height){
super.sublayout(width, getPreferredHeight());
setExtent(width, getPreferredHeight());
}

public int getPreferredWidth() {
return Display.getVerticalResolution();
}
/*
public int getPreferredWidth() {
return Display.getWidth();
}
*/
public int getPreferredHeight(){
return _height;
}
public void setHeight(int h){
_height = h;
}
private int _height;
}
__________________
Don

Handspring Visor -> Handspring Visor Deluxe -> Palm Treo 650 on VZW -> Palm Treo 700p on VZW -> Blackberry Tour 9360 on VZW
Offline  
Old 11-03-2009, 07:20 PM   #7 (permalink)
Thumbs Must Hurt
 
Join Date: Aug 2009
Model: Tour
PIN: N/A
Carrier: Verizon
Posts: 84
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Dougsg38p View Post
Where are you adding a field to the vertical field manager? I don't understand what you are trying to accomplish, and neither does the system.

A Manager takes the height required to accomodate the fields contained therein. This Manager has no fields, hence no height.
Well no matter how many fields I add to the VFM, I want the height to be the same--the screen height minus the heights of the HFM above and below it.

I'll be adding fields but don't want the HFMs to move when the scroll happens.
__________________
Don

Handspring Visor -> Handspring Visor Deluxe -> Palm Treo 650 on VZW -> Palm Treo 700p on VZW -> Blackberry Tour 9360 on VZW
Offline  
Old 11-03-2009, 10:55 PM   #8 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

Then you have to limit the extent. Look for a mthod setExtent() (if memory serves).
Offline  
Old 11-03-2009, 11:16 PM   #9 (permalink)
Thumbs Must Hurt
 
Join Date: Aug 2009
Model: Tour
PIN: N/A
Carrier: Verizon
Posts: 84
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Wirelessly posted

Yes thanks. I eventually found an something that showed it. The snippet in the other thread was simple enough to understand what was going on. The problem that I have with the "Sample Applications" is that the code is too complex to be able to really figure out what's happening.

There's a difference between seeing code and just copying it vs UNDERSTANDING the code which allows me to decide when to use method X.
__________________
Don

Handspring Visor -> Handspring Visor Deluxe -> Palm Treo 650 on VZW -> Palm Treo 700p on VZW -> Blackberry Tour 9360 on VZW
Offline  
Old 11-04-2009, 09:51 AM   #10 (permalink)
Knows Where the Search Button Is
 
Join Date: Feb 2009
Location: Quebec, Ca
Model: 8330
OS: v4.5.0.77
PIN: 30293EF0
Carrier: Telus
Posts: 15
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

An easy way would be to use setBanner(Field field) and setStatus(Field field) for your top and bottom HorizontalFieldManager.

The Banner will stick to the top of the screen and the Status will stick to the bottom. Everything in the screen will scroll between theses two managers (if they are focusable).


Thank you, have a nice day.

--
Samuel D.

Last edited by SamuelD : 11-04-2009 at 09:52 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.