Solution for EditField!

Hello

I don't know much at all them must have faced this problem and their must be a way to get through it.

EditField, it takes all the space he and especially does not show the border on the right side. I added in FlowField and Director of HorizontalField, in the two TI has the same. I want there until the end or a size, but do not have the maxsize value to show on the screen.

I mean, if I want to let the user enter 200 characters. But on the screen I want to show only up to 20 characters. rest all should be floating as normal text fields.

What can be the technique to solve this problem?

Any guide, help is very appreciated.

Thank you

Regarding the conversion of characters - the pixels: you already have an opinion on the use of font.getAdvance ().  Note, however, that different characters have different widths - go with a very wide character as 'W' and increasing his lead by the number of characters.

If you use the code from the third comment in the article that you want to limit the width, you will need to add your stuff to the sublayout it.  Something like that:

protected void sublayout(int w, int h) {
    int height;
    int width;
    Font inputFont = _editField.getFont();
    Font labelFont = _label.getFont();
    int labelSize = labelFont.getAdvance(_label.getText());
    int inputMaxSize = numChars * inputFont.getAdvance("W");
    int myMaxWidth = labelSize + inputMaxSize + 2 * (_border + _padding);
    w = Math.min(myMaxWidth, w);

    layoutChild(_label, w, h);
    ...

I scored the additional code in red. numChars is the number of characters you want to see on the screen (can be more than that if the characters are quite narrow as 'i' or 'l').

Tags: BlackBerry Developers

Similar Questions

Maybe you are looking for