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
BB_Develpoer
Posts: 130
Registered: ‎10-26-2010
My Device: Blackberry Bold 9700
Accepted Solution

Fields Alignment in manager

 hi to all  ,

 

I am making a screen which look like this 

img1.png

Now the problm i am facing is when i add another to field my view becomes clumsy somthing like image below lower portion of last to field not viewed completly

I need it to look clean as like the above pic above pic..And I can show only 2 to Number field in this area. other to field can be seen  via scroll view.

One thing i want to mention is if I click on the last field its view becomes neat and clean like the above img

 

img2.png

em talking about the to number fields only I have issue only regarding their view.Each To number field consist of an HFM have a label and a BasicEdit Field 

 

I hope I m clear about my porblem 

 

Regards

 

Developer
krishnanmurari
Posts: 80
Registered: ‎06-06-2011
My Device: bold 9000

Re: Fields Alignment in manager

Hi BB Developer.

 

Try setting the margin on the bottom.

 

That issue might arise when another field is clashing with the previous field.

 

So try settin marging to the second HorizontalField manager.

 

Let me know if it resolves.

 

Regard

Krishnan.

Developer
arkadyz
Posts: 2,268
Registered: ‎07-08-2009
My Device: various

Re: Fields Alignment in manager

Do you have a custom manager laying out your fields? Or a regular VFM and custom fields? How do you position them on the screen?

I suspect you have some wrong calculations for the vertical positions of the fields beyond the first. Something like adding the margin between the fields only once instead of on each loop cycle.

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Developer
BB_Develpoer
Posts: 130
Registered: ‎10-26-2010
My Device: Blackberry Bold 9700

Re: Fields Alignment in manager

Sorry for such late reponse my net was not responding

 

@krishnamurari   yes i m setting margins of my hfm each time i add it to vfm 

 

@arkadyz  No  i am using HFM as my custom manager (customized its only to give it width and height of my choice)

VFM is a regular mangr nothing done with it, I dont set the position just add them .Also em adding margins only once not in a loop cycle.

 

One thing i did not get is if a click on second field all drwing get ok Why is that ??

 

Regards

Developer
krishnanmurari
Posts: 80
Registered: ‎06-06-2011
My Device: bold 9000

Re: Fields Alignment in manager

Hi BB Developer,

 

If its not much to ask can you post your code so anybody who comes accross it can suggest whats the mistake.

 

Even we could have a look and tell what the error.

 

Regards

Krishnan, 

Developer
BB_Develpoer
Posts: 130
Registered: ‎10-26-2010
My Device: Blackberry Bold 9700

Re: Fields Alignment in manager

This is the code to create the hfm field

 

	public VOPHorizontalFieldManager getToNumberField(String number) {
		 // label field 
		LabelField label = new LabelField ("To:" , FIELD_LEFT){
			protected void paint(Graphics graphics) {
				graphics.setColor(Color.WHITE);
				super.paint(graphics);
			}
		};
		label.setMargin(8,6,4,8);
		//Container manager
		VOPHorizontalFieldManager hfm = new VOPHorizontalFieldManager(Display.getWidth(), 37){
			protected void paintBackground(Graphics g) {
				super.paintBackground(g);
		    	g.clear();
		    	g.drawBitmap(0, 0, Display.getWidth(),37, background, 0, 0);
		    }
		};
	
		//number input field
		BasicEditField field = new BasicEditField("", number, 30, BasicEditField.FILTER_DEFAULT) 
		{
			protected void paint(Graphics graphics) {
				graphics.setColor(Color.BLACK);
				super.paint(graphics);
			}

			protected void paintBackground(Graphics g) {
				g.setColor(text_Field_Border_Color);
				g.drawRoundRect(4, 0, Display.getWidth()-48, this.getHeight() , 6,6);
				g.setColor(Color.WHITE);	
				g.fillRoundRect(4, 0,Display.getWidth()- 48, this.getHeight() , 6,6);
				g.setColor(Color.BLACK);
				super.paintBackground(g);
			}
		};
		field.setPadding(4,6,4,6);
		field.setMargin(4,4,4,6);
		
		hfm.add(label);
		hfm.add(field);
		return hfm;
	}

 

I just add a new hfm to a basic VFM when i clik a menuiten add.VFM is than added to the screen

my vfm is usual vfm only on thing is had override its sublayout method to make a length restriction

VerticalFieldManager vfm = new VerticalFieldManager(
  protect void sublayout(int maxWidth , int maxHeigh){
     super(maxWidth , 80 );
     setExten(maxWidth , 80);
}
});

 

 i hope now you can understand better

 

Developer
krishnanmurari
Posts: 80
Registered: ‎06-06-2011
My Device: bold 9000

Re: Fields Alignment in manager

Hi BB Developer,

 

Thanks for posting the code on my request.

 

I am exactly not so sure but do try this.

 

Set margin on bottom as 10 or fifteen. Cause i feel the horizontal field manager is taking only the place of the basic edit field so it might be paint it on top of the other.

 

This is just a suggestion.

 

Let me know if it works.

 

Regards

Krishnan.

Developer
arkadyz
Posts: 2,268
Registered: ‎07-08-2009
My Device: various

Re: Fields Alignment in manager

Can you post the sublayout code of VOPHorizontalFieldManager? There's so much that can go wrong there, even just trying to limit the size of the manager...

You can drop super.paintBackground in your paintBackground code - it will be painted over anyway.

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Developer
BB_Develpoer
Posts: 130
Registered: ‎10-26-2010
My Device: Blackberry Bold 9700

Re: Fields Alignment in manager

Hi

 

I had posted the method in my pervious post ,

here is my whole class

 

class VOPHorizontalFieldManager extend HorizontalFieldManager{
    VOPHorizontalFieldManager(int w , int h){
       this.width = w;
       this.height = h ;
   }
   
   protect void paint(){
       setExtent(width, heigth);
   }
   
   protected void paintBackground(Graphics g) {
	super.paintBackground(g);
	g.clear();
    	g.drawBitmap(0, 0, width,height, background, 0, 0);
     }
}

 Regards

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

Re: Fields Alignment in manager

Have you really got this coded?

 

   protect void paint(){
       setExtent(width, heigth);
   }

 

Or is this your sublayout method renamed.