08-24-2010 06:43 AM
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);
Solved! Go to Solution.
08-24-2010 07:47 AM
Try creating your RichTextField with USE_TEXT_WIDTH style bit.
08-24-2010 07:58 AM
thanks arkadys, I would try it and get back to you..
08-24-2010 08:00 AM
looks like there is no such style as "USE_TEXT_WIDTH" ..i've got USE_ALL_WIDTH and USE_ALL_HEIGHT instead..
thanks
08-24-2010 08:03 AM
There is USE_TEXT_WIDTH specifically in RichTextField - don't use just Field.USE_TEXT_WIDTH, use RichTextField.USE_TEXT_WIDTH.
08-24-2010 08:08 AM
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.
08-24-2010 08:12 AM
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....
08-24-2010 08:36 AM
Welcome to the wonderful world of BB UI development. Banging your head at the wall is a mandatory activity here. ![]()
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...