简体   繁体   English

如何在Blackberry上处理屏幕旋转

[英]How to handle screen rotation on Blackberry

What's the proper way to handle screen rotation in Blackberry? 在Blackberry中处理屏幕旋转的正确方法是什么? I've work with different resolutions and all I have to do is handle Bitmaps and Margins in my Fields. 我使用了不同的分辨率,而我要做的就是处理我的字段中的位图和边距。 There's a requirement in my current project to manage screen rotation, and I don't know what's the technical approach to that. 我当前的项目中需要管理屏幕旋转,但我不知道采用什么技术方法。

For the records, I did a quick Google Search and all I found was information about how to disable rotation, so I'm starting to think rotation handling is kind of hard. 作为记录,我做了一个快速的Google搜索,发现的只是有关如何禁用旋转的信息,因此我开始认为旋转处理有点困难。

First, you need to override sublayout. 首先,您需要覆盖子布局。 You can use this code: 您可以使用以下代码:

protected void sublayout(int width, int height)
{       
    SetLayout();
    super.sublayout(width, height);
}

In set layout, you can set the size and position of your controls. 在设置布局中,您可以设置控件的大小和位置。 How you do this will depend on what FieldManager you use. 如何执行此操作将取决于您使用哪种FieldManager I use an AbsoluteFieldManager and have all my fields positioned and sized according to a percentage of the width and height of the screen. 我使用AbsoluteFieldManager ,并根据屏幕的宽度和高度的百分比来确定所有字段的位置和大小。 For example: 例如:

private void SetLayout()
{
    int screenWidth = Display.getWidth();
    int screenHeight = Display.getHeight();
    cmdOk.SetSize((int) (screenWidth * 0.2), (int) (screenHeight * 0.1));
    manager.setPosChild(cmdOk, 0, screenHeight - cmdOk.getHeight());
}

I hope this helps 我希望这有帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM