View Single Post
Old 11-01-2009, 10:18 PM   #1
doni49
Thumbs Must Hurt
 
Join Date: Aug 2009
Model: Tour
PIN: N/A
Carrier: Verizon
Posts: 84
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   Reply With Quote