2011-11-10 3 views

답변

8

내 라이브러리 클래스 중 하나에 정적 방법을 만들었습니다 :

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); 
    } 
} 

이 코드는 그것을 실행 한 후 생성 된 화면 작동한다는 것입니다 트릭. 따라서 첫 화면을 보여주기 전에 코드를 실행해야합니다.

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(); 
    } 
} 
1

이 코드를 사용하여 방향을 세로로 설정할 수 있습니다. 그 후에 장치가 가로 방향으로 유지 되더라도 방향은 변경되지 않습니다.

Ui.getUiEngineInstance().setAcceptableDirections(Display.DIRECTION_PORTRAIT); 
관련 문제