JoeAdeoye
JoeAdeoye

Reputation: 180

Fixed height EditField in BlackBerry

I am new to blackberry development and I am currently writing my first application where I ran into a problem. I want to implement two types of EditField

  1. An EditField that will have the maximum height of one row. If text are entered into this field, when the text reach the width of the EditField, the field should NOT expand i.e. It should maintain its single line form and text should move inward to the left of the field instead for it to expand. A typical example is the search bar of Blackberry app world. I want an EditField that works exactly the same way like that of BlackBerry app world's search bar.

  2. I also want an EditField that has a maximum height of 10 rows, when text entered is more than 10 rows, the field should display a vertical scroll bar so that the field's content should be able to be scrolled. A typical example is BBM's chat field

I have read some articles here http://supportforums.blackberry.com/t5/Java-Development/How-to-create-a-notepad-kind-of-multiline-editor/td-p/443301 but it doesn't seem to help

Pls any help will be appreciated. Thanks

Upvotes: 0

Views: 35

Answers (1)

Peter Strange
Peter Strange

Reputation: 2650

Searching the BB Forum, I found this article:

Sample Code - Scrollable one-line text input field

The relevant code appears to be:

public class OneLineTextField extends HorizontalFieldManager {
    private EditField _editField;

    public OneLineTextField(String label, String initialValue, int maxChars, long style) {
        super(HORIZONTAL_SCROLL);
        editField = new EditField(label, initialValue, maxChars, style | EditField.NO_NEWLINE | EditField.FOCUSABLE | EditField.EDITABLE);
        add(editField);
    }

    public String getText() {
        return editField.getText();
    }
    ...
}

but I recommend you review the article.

Upvotes: 0

Related Questions