EditField in Black Berry - blackberry

I want to create the EditField which allow Numeric Values, Comma and other values are ignore in Blackberry.
So How I can achieve this by programming code ?
Thanks.

It can be achieved by using the EditField class with the Four arguments according to your need.
EditField ef = new EditField(0, "0", 3, EditField.FILTER_NUMERIC)
Add this field to a screen or a manager
The above code would make the field accept only the integer values. And if it is a Virtual keypad, it would not even show other characters/aplhabets on the keypad
Hope this solves your problem.
Keep Coding
Cheers !!

use filter for this.....
_numberEditField = new EditField(_name, "");
_numberEditField.setFilter(TextFilter.get(TextFilter.NUMERIC));
add(_numberEditField);

Related

How to Search Specific values in a Vector and update it in Blackberry

Hi! Thanks in advance...
I am doing a code to add a string value in a Vector and show that value on a textfield and after, display that value on the editfield. And I want to make an event for that editfield to update the vector value for the Blackberry I want to make a code.
I make one customeTextField and one button field on clicking this button field the value enter on customeTextField is added to vector and create a new customeTextfield which holds the enter string.
I want to event for the another customeTextField which will update the string and vector element in blackberry.
(Blackberry code is necessary)
Try to get the index of element on the focus listener of the text field then make a code for the fieldchange listener and take the index of element and write the setElement for the vector method.

Search bar on top of the mainscreen blackberry

I want to make one search bar on top of the mainscreen and this search bar should include one editfield and one image of search icon.
Please help me...
Thanks, in advance
You need to use an HorizontalFieldManager to put editfield and image on the same line. Read here http://www.blackberry.com/developers/docs/6.0.0api/net/rim/device/api/ui/container/HorizontalFieldManager.html and here: http://www.androidadb.com/class/ho/HorizontalFieldManager.html , a simple example showing how adding two buttons in an HorizontalFieldManager. Just substitute buttons with yor needed fields.
Or you can play with GridFieldMgr:
GridFieldManager gridMgr_g = new GridFieldManager(1, 2, 0);
gridMgr_g.setColumnProperty(0, GridFieldManager.FIXED_SIZE, screenWidth-myBitmapRes.width);
gridMgr_g.setColumnProperty(1, GridFieldManager.FIXED_SIZE, myBitmapRes.width);
gridMgr_g.add(new EditField());
gridMgr_g.add(new BitmapField(Bitmap.getBitmapResource(myBitmapRes)));
add(gridMgr_g);

BlackBerry API 6.0. How to make a LabelField wider (to make it stop enforcing new lines)?

I have a class which extends LabelField to set font and color.
I have 2 such custom LabelFields and they display some strings of text. Those Strings are rather short, about a dozen symbols long.
The problem is that these custom LabelFields enforce new lines. They break my strings and display them in 2 lines instead of only 1 (no matter if a String is 6 or 12 characters long).
How to make these LabelFields stop enforcing new lines?
I need to have one line stay one line.
Update:
I have found the reason of that problem.
The problem was on another level, - in the process of calculation of width and height for my popup Screen which contained those LabelFields.
you can use the style LabelField.ELLIPSIS to force the single line.
like
LabelField l = new LabelField("your text",LabelField.ELLIPSIS);

BlackBerry: TreeField with BitmapField

I want to display the contacts in a TreeField like:
An image followed by a username
My understanding is that I use a BitmapField to display the image, but I don't see how to combine a BitmapField with a TreeField.
You can't use another field with a TreeField. You need to implement the TreeFieldCallback.drawTreeItem() method and do the drawing yourself
See my answer to a similar StackOverflow question: "Customising Blackberry Treefield."
In that answer, I've re-drawn each row of a TreeField along with a Bitmap image replacing the default (+)-icon of TreeField.
You can do it by using graphics.drawBitmap() method and graphics.drawText() method and using the index and y parameters inside the drawTreeItem() method of class which implements TreeFieldCallback interface

Delphi 7 - cxDBGrid Column : How to display a check mark next to some character string

I have to display in a cxdbGrid column 'Test √', and I got the check mark by using a symbol font but the rest of the characters changed.
I don't have an answer if you do actually need to have the check as part of actual text in the text column. I don't think I've ever seen an app that did it that way though. The usual way of doing this is to add a column to the left or right of the text column in question and have the new column use a checkbox control. Then just set the value of the checkbox column to true or false.
It's quite common to include some type of image to represent the state of a column in a grid control. You could implement your own OnCustomDrawCellEvent to put an icon image there, instead of text and a font. Below is a link to a tutorial of how to accomplish this.
How to draw an icon along with the text in a grid cell

Resources