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
Posts: 100
Registered: ‎06-21-2010
My Device: Not Specified
Accepted Solution

HorizontalFieldManager not displaying content

HI all,

 

I am presently working on a GUI application..

 

I want to have a forms screen where you have something like this

 

----------------------------------------------------

                  -------------------------------

Name:      |                                      |

                   -----------------------------

                  -------------------------------

Adress    |                                         |

                  _________________

 

---

--- etc

--

--

______________________________

 

 

just a label and a box for each row.. thats the sort of thing i want to do.

 

I currently have an extention of  MainScreen class that should draw the label text twice on each line

 

 

eg

 

_________________________

 

Name:              Name:

 

Customer:      Customer:

 

--etc

_________________________

 

butit doesnt do this. It just prints out  the "Name: " label once and thats it. Doesnt even produce any errors. Please any hints on what could be going wrong?

 

I have pasted my code below to give you a beetter idea of what I was aiming to achieve.

 

cheers

 

 

public class RelayScreen extends MainScreen{
	HorizontalFieldManager [] hfmList;
	String [] labels = {"Names : ","PMRNumber1 : ","PMRNumber2 : ","PMRNumber3 : ","Connection Code : ", "Geography : "};
	
	public RelayScreen(){
        
		hfmList = new HorizontalFieldManager[6];
		for(int i = 0; i < hfmList.length; ++i){
			
			hfmList[i] = new HorizontalFieldManager();
			hfmList[i].add(new RichTextField(labels[i]+" 1 "));
			hfmList[i].add(new RichTextField(labels[i]+" 2 "));
			add(hfmList[i]);
		}
	}
}




//Call back function that handles a form button click
FieldChangeListener formButtonListener = new FieldChangeListener() {   
			public void fieldChanged(Field field, int context) {   
				RelayScreen cs = new RelayScreen();
				agent.pushScreen(cs);
				
			}   
		};   
		formButton.setChangeListener(formButtonListener);

 

 

 

 

 

 

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

Re: HorizontalFieldManager not displaying content

Try creating your RichTextField with USE_TEXT_WIDTH style bit.

----------------------------------------------------------
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
Posts: 100
Registered: ‎06-21-2010
My Device: Not Specified

Re: HorizontalFieldManager not displaying content

thanks arkadys, I would try it and get back to you..

Highlighted
Developer
Posts: 100
Registered: ‎06-21-2010
My Device: Not Specified

Re: HorizontalFieldManager not displaying content

looks like there is no such style as "USE_TEXT_WIDTH" ..i've got USE_ALL_WIDTH and USE_ALL_HEIGHT instead..

 

thanks

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

Re: HorizontalFieldManager not displaying content

There is USE_TEXT_WIDTH specifically in RichTextField - don't use just Field.USE_TEXT_WIDTH, use RichTextField.USE_TEXT_WIDTH.

----------------------------------------------------------
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
Posts: 100
Registered: ‎06-21-2010
My Device: Not Specified

Re: HorizontalFieldManager not displaying content

I hope you can see this picture because this is what i am getting.. Its only one label in each row instead of two..

 

thanks

 

let me know if you cannot view the picture.

 

2991i51DD730346CEA05A

Developer
Posts: 100
Registered: ‎06-21-2010
My Device: Not Specified

Re: HorizontalFieldManager not displaying content

Dude..who are you? can you explain this miracle that you have just perofrmed? i tried the USE_TEXT_WIDTH and it worked.

 

What does that style do?

 

by defualt shouldnt everything just work fine?

i thought it was only when you wanted optimum performance or a certain feel that you should manipulate the style bits or extend the Field..

 

But anyhow thanks..you have helped me..

 

Second question coming right up! its about the box this time....

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

Re: HorizontalFieldManager not displaying content

Welcome to the wonderful world of BB UI development.  Banging your head at the wall is a mandatory activity here. Smiley Wink

 

Seriously, though - BlackBerry framework gives you some very basic stuff, on one hand, and the ability to tinker with it to a very low level of details, on the other hand.  RichTextField, fortunately, has this style bit which tells it to limit its extent on the screen. Other fields (ButtonField is a good example) are economic by default unless you tell them USE_ALL_WIDTH. But most of TextField descendants are width-hungry and grab all they are given (as though having USE_ALL_WIDTH by default). If you start using EditField you will get this situation again - and there will be no USE_TEXT_WIDTH to help you.

 

With EditField you will have to override its layout and inside call super.layout(yourDesiredWidth, maxHeight) (maxHeight being the second parameter to layout(int maxWidth, int maxHeight) method). If you have more questions, start another thread.

 

Oh, and here is a very good read on how these things work (read both responses by Ted_Hopp there):

Question Regarding setExtent and getPreferredWidth...

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!