Storm 上的锁定方向
我需要在 Storm(和 Strom 2)设备上以纵向模式锁定我的应用程序。 我为此使用 Ui.getUiEngineInstance().setAcceptableDirections(Display.DIRECTION_PORTRAIT);
。
问题是这样的:
屏幕方向仅改变一次 设备旋转到一个方向 由所提供的方向支持 参数。
(源)
如果用户的设备处于横向模式并打开应用程序,则应用程序将以横向模式打开,并且仅当/如果用户将设备旋转到纵向模式时才会锁定到纵向模式。
即使在我上面描述的情况下,有什么方法可以强制应用程序处于纵向模式吗?
I need to lock my application in portrait mode on a Storm(and Strom 2) device.
I use Ui.getUiEngineInstance().setAcceptableDirections(Display.DIRECTION_PORTRAIT);
for this.
Here is the problem:
The screen direction only changes once
the device is rotated to a direction
supported by the provided direction
parameter.
(source)
If the user has the device in landscape mode and opens the application, the application will open in landscape and will only lock to portrait mode when/if the user rotates the device to portrait mode.
Is there any way to force the application in portrait mode even in the case I described above?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我创建了一个从应用程序的
main()
方法调用的静态方法。请参阅我对此问题的回答中的完整代码: 如何修复 BlackBerry 中垂直和纵向屏幕的对齐问题?
I have made a static method that I call from my application's
main()
method.See the full code in my answer to this question: How to fix alignment for vertical and portrait screen in BlackBerry?
可以通过创建一个扩展 MainScreen 类的自定义类来解决该问题,该类接受 nextScreenObject 作为构造函数中的参数
,然后使用
UiApplication.getUiApplication.pushModalScreen(nextScreenObj);
//这将锁定屏幕
因此,每当您按下任何屏幕时,都会创建此自定义类的对象,并将屏幕对象作为参数发送给此构造函数
例如:让 NewCustomClass 成为扩展 MainScreen 的自定义类
然后在推送新屏幕时,您可以
NextScreen nextScreenObj = new NextScreen(..args..);
NewCustomClass PushObj = new NewCustomClass(nextScreenObj);
如果问题解决了请告诉我。
It can be solved by creating a custom class which extends MainScreen class which accepts the nextScreenObject as an argument in the constructor
and then by using
UiApplication.getUiApplication.pushModalScreen(nextScreenObj);
//This would lock the screen
So whenever you push any screen create an object of this custom class and send the screen object as an argument to this constructor
Eg: Let NewCustomClass be your custom class which extends MainScreen
then while pushing a new screen you can
NextScreen nextScreenObj = new NextScreen(..args..);
NewCustomClass pushObj = new NewCustomClass(nextScreenObj);
Let me know if the problem is solved.