Sam-In-TechValens
Sam-In-TechValens

Reputation: 2519

Setting the height of ObjectChoiceField in BlackBerry?

I have used the ObjectChoiceField in my application. The choice are very long, mostly the choices are of two line which increases the height of the ObjectChoiceField and makes my UI unstable. I had used "single line = true" property in Android which allows long text line to show in ellipses(...).

Can I do that in BlackBerry as don't want to change the height on run time. Also I don't want to use custom ObjectChoiceField. please suggest me according to my conditions what can I do.

Currently I am using follwing code.

ObjectChoiceField _productLineOCF =new ObjectChoiceField("",_productLineArray,plSetTo1,Field.FIELD_RIGHT){
    protected void layout(int width, int height) {
        setMinimalWidth(width - 61);
        super.layout(width, height);
    }
};

Sample output of the above code:

Sample output

Upvotes: 3

Views: 685

Answers (1)

Rupak
Rupak

Reputation: 3674

Try this,

String choices[] = {
        "Choice 1 - Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
        "Choice 2",
        "Choice 3" };

long styleBit = Field.FIELD_RIGHT | ObjectChoiceField.FORCE_SINGLE_LINE;

ObjectChoiceField ocf = new ObjectChoiceField("", choices, 0, styleBit) {
    protected void layout(int width, int height) {
        setMinimalWidth(width - 61);
        super.layout(width, height);
    }
};

Upvotes: 6

Related Questions