Example PopupScreen

Can anyone show me an example application with the code that appears as a popupscreen instead of a full screen for the storm?

Having a little difficult here...

Hello

That's what you're looking for...

http://www.BlackBerry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800505/800256/...

NQT.

Tags: BlackBerry Developers

Similar Questions

  • UiApplication using PopupScreen

    Hi all

    This is my first post on this amazing forum. I read through many large threads with lots of answers to the questions I had in my short time developing applications for the BlackBerry smartphone. Unfortunately, I hit my first stumbling block, which I'm sure will be very easy, but hey, we all start somewhere.

    The question that I'm doing the experience simply creates a PopupScreen in the mainevent thread and wait for user input before continuing. In my days of Swing I just use an observable model and notify the application of change, but I seem to have trouble with this concept here. I tried to use the pushModalScreen and the pushGlobalScreen of the UiApplication class methods, but both give me a runtime... error pushGlobalScreen called by thread of non-event.

    It seems to me missing something probably just in front of me, but I would appreciate help on this. I just use this example using the 9000 Simulator that is packed with the JDE v4.6

    public static void main(String[] args) {
            MyApp app = new MyApp();
            app.enterEventDispatcher();
        }
    
        MyApp() {
            final PromptTest prompt = new PromptTest();
            invokeLater(new Runnable() {
                public void run() {
                    pushGlobalScreen(prompt,1,UiApplication.GLOBAL_MODAL);
                }
            });
            continueProcess();
        }
    
        public void continueProcess() {
        // do something with input from PopupScreen
        }
    }
    

    Thank you.

    Well, I'm a little bit embarrassed. I have solved my problem. Using just pushScreen, like any other approach and all simply migrate code to deal with in my fieldChangeListener. I don't know what I thought earlier. I'm sorry to have lost someone's time on this one.

  • Menu remains visible after you make the selection, and does not show Popupscreen

    Hey. Unable to get a (a gaugefield) on a Popupscreen progress bar to show. It is called from a menu. The user clicks a menu item, and a method is called. The method among other pushes a Popupscreen containing a Gaugefield on display battery-code below. Then, he starts a thread which downloads an image and using join() to wait for it complete (long story). Then, in the thread of events, it appears the Popupscreen.

    The menu does not disappear when you click on it in the Simulator (JDE 4.7, the Bold 9700 sim), but the download happens. Once the download is complete, the menu disappears, the Popupscreen is shown and he tried to pop() Popupscreen, causing an IllegalArgumentException.

    I tried to split the method into two methods, the download happened in the 2nd method, because I read the forum search that the UIEngine don't update the display until the method finishes (it runs in the event thread). But it made no difference...

    How can I get this menu to disappear immediately and the push (popup) to work?

    See you soon!

    Justin.

                            progressbar = new GaugeField("", 0, 100, 50, GaugeField.NO_TEXT);
                            progress = new PopupScreen(new FlowFieldManager()) { protected void OnDisplay() { super.onDisplay(); /*cancelButton.setFocus();*/  }  };
                            globalTiles.pushScreen(progress);
    
                            progress.add(new LabelField("Downloading (rest of) picture ..."));
                            progress.add(progressbar);
                            progress.setFocus();
    
                            if (!threadbg.isAlive()) {
                                       threadbg = new ThreadForBgDownload();
                                       threadbg.start();
                            }
                            else {
                                       // Show the progress bar, mostly complete (it is running and was in the bg). Game will start after last bit done
                            }
    
                            threadbg.join(); // Wait for download thread to complete and 'die'
    
                            globalTiles.popScreen(progress);
    

    Rule #1: all display updates should occur on the thread event or synchronized on the lock of the event.

    Rule #2: the thread of events (or now the lock of the event) should never be blocked by lengthy operations.

    The scenario you sketched out is usually handled like this: menu item run() method don't whatever immediate user interface updates are necessary and starts a worker thread. It does not wait until the thread ends before returning. (If so, updates the user interface include pushing a "Please wait" or progress pop up). The worker, at the same time, begins to do its stuff. When it's time to update the user interface (either because the task is completed or to view progress) the worker thread usually called invokeLater (Runnable) (a method in the Application class) where the executable run() method updates the user interface. If the worker thread must receive user input in his work, he can use invokeAndWait (Runnable), where the executable not all interactions of the user and stores the user entry somewhere so that the worker thread can grab after invokeAndWait() returns.

    Although the synchronization on event lock works perfectly well, it is more common for some reason any to invoke a Runnable, perhaps because the latter clearly encapsulates in a separate object the work to be done on the event thread.

    The above policy is the basis of the excellent Peter Strange example I linked to before.

  • popupscreen extention problem

    Hello everyone.

    I am trying to open a java popupscreen of an extention and shows me the following error message, telling me that I am doing wrong or if it is an example.

    java.lang.IllegalStateException: interface engine user accessed without holding the lock on the event.

    package samplecode;
    
    import net.rim.device.api.script.ScriptableFunction;
    import net.rim.device.api.system.Alert;
    import net.rim.device.api.ui.UiApplication;
    
    public final class AlertFunction extends ScriptableFunction {
    
        public Object invoke(Object obj, Object[] args) throws Exception {
           if (!Alert.isVibrateSupported()) {
              return UNDEFINED;
           }
           if (args.length == 1) {
              int duration = ((Integer)args[0]).intValue();
              Alert.startVibrate(duration);
              box vbox = new box();
                UiApplication.getUiApplication().pushScreen(vbox);
                //UiApplication.getUiApplication().popScreen(vbox);
           }
           return UNDEFINED;
        }
    }
    
    package samplecode;
    
    import net.rim.device.api.ui.Field;
    import net.rim.device.api.ui.component.ButtonField;
    import net.rim.device.api.ui.component.LabelField;
    import net.rim.device.api.ui.container.PopupScreen;
    import net.rim.device.api.ui.container.VerticalFieldManager;
    
    public class box extends PopupScreen {
    
        /**
         *
         */
        public box() {
            super(new VerticalFieldManager());
            LabelField labelField = new LabelField("Popup Screen",
                    Field.FIELD_HCENTER);
            add(labelField);
            ButtonField btnfldOk = new ButtonField("OK", ButtonField.CONSUME_CLICK
                    | Field.FIELD_HCENTER);
            btnfldOk.setMinimalWidth(100);
            add(btnfldOk);
            ButtonField btnfldCancel = new ButtonField("Cancel",
                    ButtonField.CONSUME_CLICK | Field.FIELD_HCENTER);
            add(btnfldCancel);
            // TODO Auto-generated constructor stub
        }
    
    }
    

    Hi chicoxml,

    This line is your problem:

    UiApplication.getUiApplication () .pushScreen (vbox);

    The problem and the solution is very well described in this thread. Check it out and let me know if it solved for you:

    http://supportforums.BlackBerry.com/T5/Java-development/updating-UI-from-system-thread-UI-engine-ACC...

  • Get popupscreen user input and store it in the variable

    Hello world. I have a screen that is pushed to start the application

    pushScreen (new SPScreen());

    In the constructor of the form, I push an extension of popupscreen in the stack to get an int from the user through TextField amount.

    UiApplication.getUiApplication () .pushGlobalScreen (new SplashScreen(), 1, UiEngine.GLOBAL_SHOW_LOWER);

    In the popuupscreen, I store the entry under int amount;

    public void fieldChanged (field field, int context) {}

    name = nameTxt.getText ();

    quantity = Integer.parseInt (amountTxt.getText ());

    Close();

    }

    };

    Now I want int amount; in my screen to shoot the user supplied value and whenever you click on a button Add the amount in total, each time increasing the total amount.

     

    public static int amount;

    total int = 0;

    ...

    amount

    = OptionScreen.amount;

    Total = total + amount;

    No matter how many times you press the Add button it only changes the total amount. For example, if I enter 6 as the quantity and press the button 3 times I want the total 18 years, but the total is still only 6.

    I'm sure there's probably a way to pass a reference to the variable, but I have a similar situation where I have a variable which is accessible by a certain screens and can be changed in multiple screens as well.  I delcare a class called globalVars and put the variable.

    public class globalVars {
    
        public static int total;
    
    }
    

    Do only access you anywhere with globalVars.total.

    Kind regards

    Scott

  • PopupScreen + LocationListener

    I have tried to create a Popup (PopupScreen) that displays "search satellite...". "while I'm waiting for LocationListener to call. Once it is called, I put the location listener to null, and I try to fill the PopupScreen. No matter what I do I can't close. I get an IllegalStateException.

    I looked in the forums, I've seen 100 threads that tell you how to do this, people link to these articles KB, but nothing works. I don't know if I'm just not thinking clearly, but I just can't understand it.

    Basically... I'm trying to do something like:

    screen = new PopupScreen(); pertend this is a message in it

    UiApplication.getUiApplication () .pushScreen (form);

    Critier criteria = new Criteria();

    LocationProvider provider = new LocationProvider.getInstance (criteria);

    provider.setLocationListener (new MyLocationListenerHere (this));

    Then in my MyLocationListenerHere I want to lie...

    MyLocationListener (form) {}

    This.some_holder = screen;

    }

    {public locationUpdated Sub (LocationProvider provider, a place)

    do things for contact information

    UiApplication.getUiApplication () .popScreen (this.some_holder.screen);

    }

    IllegalStateException

    Note: I just write this code now for this post, it gives you a good example of what I'm trying to do. If anyone can help me it would be GREATLY appreciated.

    locationUpdated() runs as a background Thread.  In my view, that it is running in your Application, just to get your pop on your event feed!  Usually, it's pretty easy.  Assuming this works, then that's all you need:

    {public locationUpdated Sub (LocationProvider provider, a place)

    Final anti-pop = this.some_holder.screen;

    UiApplication.getUiApplication () .invokeLater (new Runnable() {}

    public void run() {}

    UiApplication.getUiApplication () .popScreen (anti-pop);

    }

    };

    do things for contact information

    }

    This code is written from memory, not tested, but I hope that you can find in her compilation errors.

    Let us know how you go.

  • Problem scrolling in PopupScreen

    Hello

    I added a PopupScreen to my application that will display a given text. When the text is displayed, scroll arrow appears indicating that there is more text to be displayed, however it doesn't let me scroll when I click on the down (tests on a BlackBerry with a trackball).

    The text is displayed in a LabelField (which I believe is not Focusable by default), but even when I say new LabelField ("text", Field.FOCUSABLE), it still doesn't let me scroll down. I tried to add other areas (for example, EditFields) and it seems to work. So I think the problem is with the update?

    Can someone tell me why this is? Here is my code:

    package com.kflicks.ui.Screens;
    
    import java.util.Vector;
    
    import net.rim.device.api.system.*;
    import net.rim.device.api.ui.container.*;
    import net.rim.device.api.ui.*;
    import net.rim.device.api.ui.component.*;
    
    public class SynopsisScreen extends PopupScreen implements KeyListener {
    
        Vector results;
    
        LabelField label;
    
        public SynopsisScreen(String synopsis) {
            super(new VerticalFieldManager(VERTICAL_SCROLL | VERTICAL_SCROLLBAR),
                    Field.FOCUSABLE);
    
            label = new LabelField(synopsis);
            add(label);
        }
    
        public void close() {
            UiApplication.getUiApplication().popScreen(this);
        }
    
        // ///////////////////////////////////
        // / implementation of Keylistener
        // ///////////////////////////////////
        public boolean keyChar(char key, int status, int time) {
            // intercept the ESC key - exit the app on its receipt
            boolean retval = false;
            switch (key) {
            case Characters.ENTER:
                break;
            case Characters.ESCAPE:
                close();
                break;
            default:
                retval = super.keyChar(key, status, time);
            }
            return retval;
        }
    
        /** Implementation of KeyListener.keyDown */
        public boolean keyDown(int keycode, int time) {
            return false;
        }
    
        /** Implementation of KeyListener.keyRepeat */
        public boolean keyRepeat(int keycode, int time) {
            return false;
        }
    
        /** Implementation of KeyListener.keyStatus */
        public boolean keyStatus(int keycode, int time) {
            return false;
        }
    
        /** Implementation of KeyListener.keyUp */
        public boolean keyUp(int keycode, int time) {
            return false;
        }
    }
    

    Try to exchange your LabelField to a RichTextField and see if that solves your problem.

  • Need help understanding this example of Blackberry.

    Link to the official example here.

    I'm trying to understand it. It seems that it creates a screen of the PopupScreen UI class that is built into the RIM. Now where exactly it display this screen?

    Of after what I have read and understood the example doesn't show how to create a popup screen and manage entries, but it does not show how to display it.

    For example, if I have another class that implements the class screen, how I would invoke this PopupScreen?

    Thanks a bunch for the help!

    Only, it shows the implementation of the class of the screen.

    To display this screen, you would 'push' the screen using UiApplicaiton.pushScreen () or UiApplication.pushModalScreen)

  • Width of Popupscreen problem

    Hello

    Looks like Popupscreen width has a strict limit.

    On 8800 for example, it seems that there the maximum width of 288, when the width of the screen is 320.

    As a result, it cut my content on the right.

    He knows question/made? Does perform a work around?

    Thank you.

    Forget this workaround option - like that I had not suggested it.

    You should be able to substitute sublayout in your PopupScreen - I just tested.  Here's a proposed code.

        public void sublayout(int width, int height) {
            super.sublayout(Display.getWidth(),height);
        }
    

    When I say tested, there, I just ran to the top of the test code I set a breakpoint in the sublayout and updated values.  Worked well for me, but because of the border, you may not be able to use the full width.  Please try it out.  If it doesn't, then we can study something else.

  • The Manager is null in PopupScreen

    Ignore this thread, I just made a stupid mistake in my own code and it had nothing to do with PopupScreen.

    Hi all

    I have the following problem, and I can't believe my eyes... I get off PopupScreen, I pass a new handler instance to the constructor inherited super caller and then on the line following getManager() returns null. (And of course add calls fail). For example:

    public class that dialogue extends PopupScreen implements {FieldChangeListener}

    [....]

    Public dialogue (properties conf, string text [, String String Yes, no, listening to the listener) {}
    Super (new VerticalFieldManager());

    log.log ("Manager ="+ getManager()); say the Manager is null
    This.Listener = listener;
            
    for (int i = 0; i)< text.length;="" i++="" )="">
    Add (new LabelField (text [i], Field.FIELD_HCENTER)); Throws NPE, while the text and the text [i] is NOT null. Without a doubt.
    }

    Has anyone seen anything like this before? I checked some of my first projects and (unsurprisingly), I could do the same thing without guile ay. (In fact it is wrong one could do here, since calling the inherited constructor must be the first statement...) Now, this fails for me on 4.2.1 4.5.0 and 4.7.0.

    At first, I thought that's a few threads question undocumented (I was bringing together the UI in a GUI thread not before calling enterEventDispatcher), but that works in all of my projects and I changed the boot in the end sequence, so who know it happens after the call to enterEventDispatcher. I tried to move it to the thread of the event, but it still does not work as a result. (As I look at the code it shouldn't be there all multithreaded processing issues.) At least as long as it's a java virtrual machine and not only something similar.)

    Laszlo

    ... and how to get away from the problem, sleep and talk (post on the forum) help to solve... I have accidentally overridden method add to be able to add components from the outside to a specific part of the window (just like with the standard dialog box class). Which was to throw the exception when it is called from the constructor as the manager used in there would be initialized later. Sorry, my bad, thanks for your efforts .

  • I need the popupScreen to go down...

    I have a popup screen code which I have pasted below... every time you press the red button or the previous button the screen freezes... I need to go in the background when you press on the back or on the red button... How can she... ?

    class PopupScreenForAlphanumericInput extends PopupScreen
    {
        private AutoTextEditField alphaInputField;
    
        public PopupScreenForAlphanumericInput(String message,String defaultResponse)
        {
           super(new VerticalFieldManager(),Field.FOCUSABLE);
           LabelField question = new LabelField(message);
           alphaInputField = new AutoTextEditField("", defaultResponse, 100, AutoTextEditField.AUTOCAP_OFF);
           ButtonField bf = new ButtonField("submit");
           add(question);
           add(new SeparatorField());
           add(alphaInputField);
           add(bf);
        }
    }
    

    I have the screen using pust

       popS= new PopupScreenForAlphanumericInput(message,defaultResponse); 
    
                UiEngine ui = Ui.getUiEngine();
                Screen screen = popS;
                ui.pushGlobalScreen(screen, 1, UiEngine.GLOBAL_QUEUE);
    

    You push the screen with the overall modal attribute. It will retain the focus until the licensee or a higher priority screen is pushed across the world (for example, entering the call screen).

  • PopupScreen unusual behavior

    I am running with a storm of BB under JDE 4.7

    One area that concerns me is the behavior of the screens when alphablending participates.

    I have 2 problems now I am trying to solve with PopupScreens.

    First of all, I got a test application that I ran with a simple PopupScreen with a single ButtonField and I set the alpha value to 50 on the bottom. I used the call the PopupScreen itself setBackground (is derived from screen - Manager - field, and field a call to setBackground). Now with this call, the alpha is set to 50, and I see it very well in the Simulator.

    Now, the PopupScreens constructor requires a new VerticalFieldManager be sent in. If I use this Manager to its setBackground function call, I see a few alpha but much less... as he is set to 200 or something.

    Now there are several (lets call these areas for lack of a better term) in the PopupScreen. It is for the field of the screen itself and one for the Manager. I think what is happening here is that I put the alpha for the two "regions" and the result is that the whole 'widget' is defined on an alpha of 50, while the area inside the PopupScreen is as another area that is drawn with the same color and alpha is set to 50 too. The result is alpha to alpha, making it less transparent and I noticed that even the border has a few alpha and who is the alpha of the Manager.

    So my first question is... Exceeds my correct assessment? If so, I'll need to alpha using only the PopupScreen setBackground calls... it seems to work better.

    My second question is that I can't get either version of this application to run on the device itself. Now, this app has been changed from one that used a screen at the start (and it worked fine on the device), but when I changed to the PopupScreen and the PushGlobalScreen place in the UiApplication, it won't work. It gives me a message saying:

    "Error at startup test: 'test' may not contain the classes in com.rim, net.rim, net.blackberry.java or javax packages.

    I believe that this message is one that is normally given when proof is required. However, I don't see any warnings of certification in the Javadocs for the objects or calls I use.

    Any ideas?

    Here is the source code for a version... Sorry for all the commented code (I'm currently doing run :-)

    /**
     * test.java    Tests various features that this utility may use.
     *
     * Copyright (C) 2009, IPPUB. All rights reserved.
     */
    package com.rim.bbtools.source;
    
    import net.rim.device.api.ui.*;
    import net.rim.device.api.ui.component.*;
    import net.rim.device.api.ui.container.*;
    import net.rim.device.api.ui.decor.*;
    import net.rim.device.api.i18n.*;
    
    /*
     * BlackBerry applications that provide a user interface
     * must extend UiApplication.
     */
    public class test extends UiApplication
    {
            private Manager m_mgr;
    
            public static void main(String[] args)
            {
                    //create a new instance of the application
                    //and start the application on the event thread
                    test theApp = new test();
                    theApp.enterEventDispatcher();
            }
            public test()
            {
                    m_mgr = new VerticalFieldManager();
                    //display a new screen
                    pushGlobalScreen(new testScreen(m_mgr), Integer.MIN_VALUE + 1, 0);
                    //pushScreen(new testScreen());
            }
    }
    
    //create a new screen that extends MainScreen, which provides
    //default standard behavior for BlackBerry applications
    final class testScreen extends PopupScreen  // MainScreen
    {
            //private final static int TALPHAB    = 50;   // Set background of screen to almost Transparent
            //private final static int TALHPAF    = 200;  // Set background of Field to almost Opaque
    
            public testScreen(Manager mgr)
            {
    
                    //invoke the PopScreen constructor
                    super(mgr, Field.FOCUSABLE);
                    //super();
    
                    final Manager mymgr = mgr;
    
                    //add a title to the screen
                    //LabelField title = new LabelField("Feature test example", LabelField.ELLIPSIS
                    //                | LabelField.USE_ALL_WIDTH);
                    //setTitle(title);
    
                    // Get the HELLO string from the resources file
                    ResourceBundle resources = ResourceBundle.getBundle(testResource.BUNDLE_ID,
                            testResource.BUNDLE_NAME);
                    String hmessage = resources.getString(testResource.HELLO);
                    //add the text HELLO to the screen
                    add(new RichTextField(hmessage));
    
                    //add(new RichTextField("Hello World!"));
                    // First define button handler
                    FieldChangeListener bhandler = new FieldChangeListener()
                    {
                        public void fieldChanged(Field field, int context)
                        {
                            // First get the UiEngine
                            //UiEngine engine = getUiEngine();    // Screen function inherited
                            //int count = engine.getScreenCount();    // How many screens present now.
    
                            ButtonField buttonField = (ButtonField) field;
                            if (buttonField.getLabel() == "RED")
                            {
                                Background newback = BackgroundFactory.createSolidTransparentBackground(Color.RED,50);
                                mymgr.setBackground(newback);
                                buttonField.setLabel("BLUE");
                            }
                            else
                            {
                                Background newback = BackgroundFactory.createSolidTransparentBackground(Color.BLUE,50);
                                mymgr.setBackground(newback);
                                buttonField.setLabel("RED");
                            }
                        }
                     };
                     // Define button itself to use handler above, this one called RED
                     ButtonField buttonField = new ButtonField("RED",ButtonField.CONSUME_CLICK);     // Create RED button
                     buttonField.setChangeListener(bhandler);               // Set up button handler defined above
    
                     add(buttonField);      // Add the button to the screen.
    
            }
    
            //override the onClose() method to display a dialog box to the user
            //with "Goodbye!" when the application is closed
            public boolean onClose()
            {
                Dialog.alert("Goodbye!");
                System.exit(0);
                return true;
            }
    }
    

    Thank you

    -Donald

    I'm going to mark it as resolved because no one answered, and I guess that I am not mistaken, nothing makes sense. The only part that I haven't figured out is why it does not work on the device and I did more work to identify this problem and I suspect another problem (problem IDE), so I'll post a different question for this.

    Thank you

  • I just bought the last Apple TV - I can't seem to connect with the App Store and Siri is completely useless. This is an example of how Apple is unable to produce a useful product?

    I just bought the last Apple TV - I can't seem to connect with the App Store and Siri is completely useless. This is an example of how Apple is unable to produce a useful product?

    Hello

    Be sure to follow the instructions in this article to support > set up your Apple TV (4th generation) - Apple supported

  • I think I have to reset the SMC on my MacBook Pro, but I need MUCH more information on my MacBook Pro. For example, is the battery removable?

    I think I have to reset the SMC on my MacBook Pro, but I need MUCH more information on my MacBook Pro. For example, is the battery removable?

    Depends on what year it is.

  • Keyboard entry displays garbage - is OK in IE and Chrome. Abdelkrim will show for example 123' -! random characters every time

    When I type for example aaaaaaaaaaaa what follows is displayed asdfghjkl; ' '-the characters are different each time.

    This just started happening today. IE and Chrome doesn't and characters appear when they are typed.

    I uninstalled and reinstalled Firefox but still the same

    What security software do you have?

    Some security software a typo protection or Anti-Keylogger features that can cause this.

    Start the computer in Mode safe mode with network support Windows (on the startup screen, press F8) to see if that helps.

Maybe you are looking for