I'd like to display a large text area which uses most the blackberry screen area. What is the best GUI component for this ?
Thanks
I think LabelField whould be enough, check this:
String text = "";
for (int i=0;i<1000;i++) {
text += "word" + i + " ";
}
LabelField largeLabel = new LabelField(text, LabelField.USE_ALL_WIDTH);
add(largeLabel);
BlackBerry - Add items to a ListField
Related
i am developing a mobile app in blackberry 7,i need to create a editable text field as shown in below figure with save and clear button.initially it has to show customized edittext field with predefined width(fixed as it should not exceed the defined layout) and height,and automatically get appended by new line if user requires to enter more characters after reaching predefined space as user keeps filling the field.
i googled, but i did not get any source which is similar to this.please help me by providing any suggestion or with samples
Blackberry fields decide their size in their layout field. I'm not entirely sure what EditField does in its layout, but I was able to get the behaviour you want by setting the extent. Every time the edit field text will wrap, layout will be triggered so that it can grow.
EditField editField = new EditField()
{
private final int MIN_HEIGHT = 200;
protected void layout(int width, int height)
{
super.layout(width, height);
if (getHeight() < MIN_HEIGHT)
{
setExtent(getWidth(), MIN_HEIGHT);
}
}
};
editField.setBorder(BorderFactory.createSimpleBorder(new XYEdges(1, 1, 1, 1)));
add(editField);
Creating a Blackberry app.
Just a beginner, I have searched but couldn't find a solution for it though its common. If anyone could tell me how to show a password hint and a numeric hint for blackberry applications in Java.
Thanks in Advance!!
According to your query , you want a field that shows password hint and a numeric hint for blackberry applications ..
Well blackberry follow some different way , it will not show hint (PopUp Screen). Another way is to put some (information) Text in the [EditField][1] when EditField is empty .Here is the sample code for demonstration :-
*******************************************************
EditField _userName_edtField = new EditField()
{
protected void layout(int width, int height)
{
super.layout(width, height);
setExtent(150, height);
};
protected void paint(Graphics graphics)
{
graphics.setColor(Color.BLACK);
if(isFocus())
{
if(getTextLength() == 0)
{
setCursorPosition(0);
}
}
else
{
if(getTextLength() == 0)
{
graphics.drawText("User Name", 0, (getHeight() - getFont().getHeight()) >>1);
}
}
invalidate();
super.paint(graphics);
}
};
add(_userName_edtField);
*******************************************************
this is Just a simple EditField , you can customize the field according to your requirement if this is empty it will show "User Name" and if you enter some text the "User Name" will disappear ..
means the EditField is act like a Hint and this will help you ..!!!
[1]: http://www.blackberry.com/developers/docs/5.0.0api/index.html
Your question is too broad to get a specific answer but judging by what I believe is that you are talking about a label just above or below the text field to let user know what does the field requires. In this case you can provide a confirmation screen where user is shown the field requirement like field cannot be blank, or the field can only contain numeric values, etc.
You can store the password hint on the device database and when the user enters it wrong get the label field added on the screen displaying it as hint.
Something like this:
String storedPassword = ApplicationDAO.getStoredPassword();
if(!enteredPassword.equals(storedPassword)){
LabelField hintField = new LabelField();
hintField.setText("Your hint");
mainBody.add(hintField);
}
I'm developing a BlackBerry Native Application BB SDK 5.0.
I want the Ui of this format.
--text-- --Hyperlink-- --text--
and so on.
This means i can have hyperlinks in-between the sentences.
So when i tried to make this, i'm facing some alignment issues.
Word wrap occurs and this leaves a large white space in right side of the screen.
To simulate i have attached a prototype of my code.
LabelField mylabel1 = new LabelField("Label 11231 23123123",LabelField.FIELD_LEFT);
LabelField mylabel2 = new LabelField("Label2",LabelField.FIELD_RIGHT);
LabelField mylabel3 = new LabelField("Label 312312 3123",LabelField.FIELD_RIGHT);
LabelField mylabel4 = new LabelField("Label 41312 3123",LabelField.FIELD_RIGHT);
LabelField mylabel5 = new LabelField("Label5",LabelField.FIELD_RIGHT);
LabelField mylabel6 = new LabelField("Label6",LabelField.FIELD_RIGHT);
LabelField mylabel7 = new LabelField("Label7",LabelField.FIELD_RIGHT);
LabelField mylabel8 = new LabelField("Label8",LabelField.FIELD_RIGHT);
FlowFieldManager hr=new FlowFieldManager(FlowFieldManager.USE_ALL_WIDTH);
hr.add(mylabel1);
hr.add(mylabel2);
hr.add(mylabel3);
hr.add(mylabel4);
hr.add(mylabel5);
hr.add(mylabel6);
hr.add(mylabel7);
hr.add(mylabel8);
add(hr);
Hi i just have an EditField instance that i created this way:
EditField editField = new EditField("Name", "");
But it shows that there is no space between the label "Name" and the edit Field (fill form). I want to define a specific space between them but i wonder how to do it.
just give how much space u want in "name" as "name " like this
EditField editField = new EditField("Name : ", "");
HI all i have implement Custom BasicEditField to set hint and to input long text .
please see my code
vfm_searchBox = new VerticalFieldManager()
{
//Main.Quicksearchinput is background image for inputtext
public void paint(Graphics g)
{
g.setColor(Color.WHITE);
g.drawBitmap(0,0,Main.Quicksearchinput.getWidth(),Main.Quicksearchinput.getHeight(),Main.Quicksearchinput,0,0);
super.paint(g);
}}
There is one HorizontalFieldManager to scroll text.
hfm_searchBox = new HorizontalFieldManager(Manager.HORIZONTAL_SCROLL) ;
There is one Basiceditfield to input text .
txtSearch = new BasicEditField(BasicEditField.NO_NEWLINE)
{
public void paint(Graphics g)
{
if(super.getText().length() == 0)
{
g.setColor(Color.GRAY);
g.setFont(g.getFont().derive(Font.PLAIN,18));
g.drawText("Enter Event title or subtitle", 0, 0);
super.paint(g);
}
else
{
g.setColor(Color.BLACK);
super.paint(g);
}
}};
The BasicEditField looks nice with Backgroundimage and hint but problem is that when i am nothing input in textfield it is working as endless scroll . i have set Horizontalfield width depend on BasiceditField but its width by default set to unlimited .
hfm_searchBox.add(txtSearch);
vfm_searchBox.add(hfm_searchBox);
how to prevent endless scroll ?
Thanks in Advance !!!
What is the HorizontalFieldManager's virtual width? This refers to the scrollable space whereas the width refers to the extent on the screen. You can try extending HorizontalFieldManager and overriding the sublayout method, calling setVirtualExtent in it.
As Tamar said, the Field's Virtual Width is the key concept to keep track of.
You can see my solution to a very similar question here. I provide a full code example that's probably not too far from what you're trying to do. The code I use goes a step further, and dynamically limits scrolling only to the end of where the text currently reaches. If you don't do this, and simply set one constant virtual width, then you can have the field actually scroll too far to the right. By dynamically calling setVirtualExtent(), you always get just enough scrolling, but not too much.