在Blackberry中设置标签字段的宽度

Use*_*ser 1 blackberry

如何在Blackberry中设置标签字段宽度的宽度?

小智 5

好吧,如果你只想要快速和肮脏的东西,这应该做的工作:

LabelField lField = new LabelField("text")
    {
        protected void layout(int width, int height) {
            super.layout(width, height);
            this.setExtent(HARD_CODED_WIDTH, this.getHeight());
        }
    };
Run Code Online (Sandbox Code Playgroud)

但正确的方法是选择(或编写)一个布局管理器,它可以根据不同的屏幕尺寸和其他内容灵活地执行您想要的操作.在编写自己的经理时,RIM有一些不错的样本.搜索JustifiedEvenlySpacedHorizo​​ntalFieldManager.或者看看黑莓的想法:http://www.thinkingblackberry.com/archives/116