“pushModalScreen called by a non-event thread” thrown on event thread

后端 未结 3 1340
梦毁少年i
梦毁少年i 2020-12-21 08:53

I am trying to get my Blackberry application to display a custom modal dialog, and have the opening thread wait until the user closes the dialog screen.

fina         


        
3条回答
  •  执念已碎
    2020-12-21 09:39

    Seems as though there's a bunch of code in there that's unnecessary.

    public class Application extends UiApplication {
        public static void main(String[] args)
        {
            new Application().enterEventDispatcher();
        }
    
    private Application()
    {
        final Screen dialog = new FullScreen();
        final ButtonField closeButton = new ButtonField("Close Dialog");
        closeButton.setChangeListener(new FieldChangeListener()
        {
            public void fieldChanged(Field field, int context)
            {
                Application.getUiApplication().popScreen(dialog);
            }
        });
        dialog.add(closeButton); 
    
        // this call will block the current event thread
        pushModalScreen(dialog);
    
        System.exit(0);
       }
    }
    

提交回复
热议问题