黑莓中的 PopUpScreen 阻止事件

发布于 2025-01-03 22:09:05 字数 2381 浏览 2 评论 0原文

我正在使用弹出屏幕来显示后台上传进程的更新状态。我想取消中间的上传。我试图通过在弹出屏幕上添加按钮或使用设备的物理后退按钮来实现此目的。但应用程序似乎没有捕获任何生成的事件。

以下是我如何创建弹出屏幕并向用户显示它。

    DialogFieldManager manager = new DialogFieldManager();
                        //DialogFieldManager manager = (DialogFieldManager)getDelegate();
                        statusUpdate = new LabelField("Please Wait...");
                        manager.addCustomField(statusUpdate);
                        _gaugeField = new GaugeField("", 0, 100, 0, GaugeField.PERCENT);
                        manager.addCustomField(_gaugeField);
                        cncl_Btn = new ButtonField("Cancel",ButtonField.CONSUME_CLICK | ButtonField.FIELD_HCENTER | ButtonField.NEVER_DIRTY);
                        manager.addCustomField(cncl_Btn);
                        cancelFlag = 0;
                        cncl_Btn.setChangeListener(new FieldChangeListener()
                        {

                            public void fieldChanged(Field field, int context) {
                                //  Auto-generated method stub
                                UiApplication.getUiApplication().invokeLater(new Runnable()
                                {               
                                    public void run()
                                    {
                                        cancelFlag = 1;
                                        //onClose();//as this method exited from application
                                       // close();//this method gave me IllegalStateException
                                    }
                                 });

                            }

                        });

                        //BackUpScreen.this.addMenuItem(_viewItem);
                        popup = new PopupScreen(manager);
UiApplication.getUiApplication().pushScreen(popup);

在这行之后不久,我在这样的线程中调用实际的上传过程,

UiApplication.getUiApplication().invokeLater(new Runnable() { 
                            public void run() {
                                    //.... do other stuff I wanted done...
                                backUpThread = Thread.currentThread();
                                    uploadItems();


                            }
                    });

但是如果我按弹出屏幕内的取消按钮,它不会响应。我通过在按钮的 fieldchange 监听器方法中添加一个断点来检查这一点。

我怎样才能在黑莓上做到这一点?

I am using a popup screen to show the update status of background uploading processes. I want to cancel the uploading in between. I am trying to achieve this either by addin a button to the pop up screen or with the physical backbutton of the device. But it seems that none of the events generated are caught by the app.

Here is how I am creating a popup screen and displaying it t user

    DialogFieldManager manager = new DialogFieldManager();
                        //DialogFieldManager manager = (DialogFieldManager)getDelegate();
                        statusUpdate = new LabelField("Please Wait...");
                        manager.addCustomField(statusUpdate);
                        _gaugeField = new GaugeField("", 0, 100, 0, GaugeField.PERCENT);
                        manager.addCustomField(_gaugeField);
                        cncl_Btn = new ButtonField("Cancel",ButtonField.CONSUME_CLICK | ButtonField.FIELD_HCENTER | ButtonField.NEVER_DIRTY);
                        manager.addCustomField(cncl_Btn);
                        cancelFlag = 0;
                        cncl_Btn.setChangeListener(new FieldChangeListener()
                        {

                            public void fieldChanged(Field field, int context) {
                                //  Auto-generated method stub
                                UiApplication.getUiApplication().invokeLater(new Runnable()
                                {               
                                    public void run()
                                    {
                                        cancelFlag = 1;
                                        //onClose();//as this method exited from application
                                       // close();//this method gave me IllegalStateException
                                    }
                                 });

                            }

                        });

                        //BackUpScreen.this.addMenuItem(_viewItem);
                        popup = new PopupScreen(manager);
UiApplication.getUiApplication().pushScreen(popup);

Soon afther this line I am calling the actual upload process in a thread like this

UiApplication.getUiApplication().invokeLater(new Runnable() { 
                            public void run() {
                                    //.... do other stuff I wanted done...
                                backUpThread = Thread.currentThread();
                                    uploadItems();


                            }
                    });

But if I press the cancel button inside the popup screen its not responding. I checked this by adding a breakpoint inside the fieldchange listener method of button.

How can I do this in blackberry?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心头的小情儿 2025-01-10 22:09:05

对invokeLater(int 代码的第二位)的调用导致Runnable 在事件线程上执行。如果您在事件线程上执行的任何操作被阻止,那么 UI 将变得无响应,正如您所描述的。任何可能阻塞的调用都不能在事件线程上运行。

The call to invokeLater (int the second bit of code) causes that Runnable to be executed on the event thread. If anything you do on the event thread blocks then the UI will become unresponsive as you describe. Any calls that may block must not be run on the event thread.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文