在BlackBerry上设置EditField的高度和宽度

Use*_*ser 1 blackberry blackberry-editfield

我想EditField在我的BlackBerry应用程序中设置一个高度和宽度.

Ric*_*ier 8

您需要覆盖字段的布局方法来为您设置大小:

protected void layout(int width, int height)
{
    super.layout(customWidth, customHeight);
    setExtent(customWidth, customHeight);
}
Run Code Online (Sandbox Code Playgroud)

其中,customWidthcustomHeight已经被你在其他地方设置.

  • super.layout(customWidth, customHeight) 放下场地以使用您特殊的宽度和高度.

  • setExtent(customWidth, customHeight) 设置屏幕上字段的大小.


当您使用类似于以下代码的代码声明EditField时,可以执行此操作:

final int customWidth = Display.getWidth();
final int customHeight = 30;

Field myEditField = new EditField()
{
    protected void layout(int width, int height)
    {
        super.layout(customWidth, customHeight);
        setExtent(customWidth, customHeight);
    }

};
Run Code Online (Sandbox Code Playgroud)