如何修复对齐黑莓垂直和纵向屏幕? [英] How to fix alignment for vertical and portrait screen in BlackBerry?
本文介绍了如何修复对齐黑莓垂直和纵向屏幕?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想要做的应用程序,即使画面切换为纵向或横向的方向将不会改变UI。那怎么办?
I want to do application which will not change UI even if screen is changed to portrait or landscape direction. How to do that?
推荐答案
我已经在我的库类的一个静态方法:
I have made a static method in one of my library classes:
public static void disableOrientationChange()
{
// force app to use only portrait mode
int directions = Display.DIRECTION_NORTH;
UiEngineInstance engineInstance = Ui.getUiEngineInstance();
if (engineInstance != null)
{
engineInstance.setAcceptableDirections(directions);
}
}
诀窍的是,这个code仅适用于运行后创建的画面。所以,如果你显示你的第一个屏幕,你必须运行code。
The trick is that this code only works for screens created after running it. So you must run the code BEFORE you show your first screen.
我把从我的 Application.main(字符串参数)
方法这种方法,只需调用 enterEventDispatcher()$ C $前C>。
I call this method from my Application.main(String args)
method, just before the call to enterEventDispatcher()
.
public static void main(String[] args)
{
MyApp app = new MyApp();
/*
* BlackBerry OS 5.0.0
* Disable screen orientation changes
*/
ScreenUtils.disableOrientationChange();
// enters the event processing loop thread if required
if (!app.isHandlingEvents())
{
app.enterEventDispatcher();
}
}
这篇关于如何修复对齐黑莓垂直和纵向屏幕?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文