2012-01-16 5 views
0

J'ai essayé ce morceau de code dans ma classe UiApplication, mais j'ai une exception d'état illegal.Blackberry: limite l'application au mode portrait

Ui.getUiEngineInstance().setAcceptableDirections(Display.DIRECTION_PORTRAIT); 

Je ne veux pas que mon application change d'orientation. Je veux qu'il reste en mode portrait.

EDIT:

Comment est-il utilisé:

public class HelloWorld extends UiApplication { 


    public static void main(String[] args){ 

     Ui.getUiEngineInstance().setAcceptableDirections(Display.DIRECTION_PORTRAIT); 


     HelloWorld theapp = new HelloWorld(); 
     theapp.enterEventDispatcher(); 

    } 


    public HelloWorld(){ 

     pushScreen(new FeaturedScreen()); 

    } 


} 
+0

Utilisez-vous avant d'appeler cette UiApplication.pushScreen() – Swati

Répondre

3
DemoClass() 
{ 
    int direction = Display.DIRECTION_PORTRAIT; 
    Ui.getUiEngineInstance().setAcceptableDirections(direction); 
    pushScreen(new AppScreen(this));   
} 
public static void main(String[] args) { 
    DemoClass app1 = new DemoClass();      
    app1.enterEventDispatcher(); 
} 
1
public class HelloWorld extends UiApplication { 
    public static void main(String[] args){ 
     UiEngineInstance ui = Ui.getUiEngineInstance();//I have added this new line in your code 
     ui.setAcceptableDirections(Display.DIRECTION_NORTH); 
     HelloWorld theapp = new HelloWorld(); 
     theapp.enterEventDispatcher(); 
    } 

    public HelloWorld(){ 
    pushScreen(new FeaturedScreen()); 
    } 
} 
Questions connexes