BrowserField2 的 Blackberry 简单进度条

发布于 2024-12-28 18:24:47 字数 220 浏览 1 评论 0原文

在我的应用程序中,我有一个 BrowserField2 加载不同的页面,我想显示一个简单的旋转进度条/指示器。尽可能简单,没有百分比等 - 只是一个小动画来向用户表明正在发生某些事情。

我来自 Android 开发,那里有一个叫做 Progressbar 的东西,尽管对于 Blackberry 来说它可能被称为完全不同的东西? (黑莓的进度条似乎总是包括计算所取得的进度)。

我应该寻找什么?

In my app I have a BrowserField2 loading different pages and I want to show a simple spinning progressbar/indicator. As simple as possible really, without percent etc. - just a small animation to indicate to the user that something is happening.

I come from Android development and there such a thing is called Progressbar, though for Blackberry it maybe is called something completely different? (Progressbar for Blackberry seems to always include calculating the progress made).

What should I be looking for?

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

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

发布评论

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

评论(1

公布 2025-01-04 18:24:47

我以一种相当非正统的方式解决了这个问题,我可能不会推荐任何人,但无论如何我都会写它,因为也许它会帮助那些急于完成它的人。请记住,这是一种不好的做法。

我的应用程序基本上由 4 个按钮和一个浏览器字段组成。

要显示旋转的“加载动画”,我使用由 browserfieldlistener 触发的自定义 PopupScreen 的 alishaik786 提示(请参阅他的评论):

// BrowserFieldListener to catch when a page started loading and when it is finished
                BrowserFieldListener listener = new BrowserFieldListener() {

                            public void documentCreated(BrowserField browserField, ScriptEngine scriptEngine, Document document) throws Exception{
                                displayLoadAnimation(); 
                               // see method below
                            }           

                            public void documentLoaded(BrowserField browserField, Document document) throws Exception{
                                try{
                                    popUp.close();
                                }catch(IllegalStateException es){
                                    es.printStackTrace();
                                }
                            }
                        };

            // The method for showing the popup
            private void displayLoadAnimation(){

                    popUp = new LoadingPopupScreen();

                    UiApplication.getUiApplication().invokeLater(new Runnable() {
                        public void run() {
                            UiApplication.getUiApplication().pushScreen(popUp);
                        }
                    });
                }

然后在我的自定义 PopupScreen 中,我通过检查来检查用户在“protected boolean touchEvent(TouchEvent event)”中单击的位置event.getGlobalY() &触摸的 event.getGlobalX() 并将其与按钮的位置进行比较。如果用户在按钮的 X 和 Y 范围内按下,则弹出屏幕将关闭,并且我会触发按下按钮。

正如我所说,这是一种不好的方法(很多事情需要静态),但如果您想要一个快速而肮脏的解决方案,它就可以工作。

I solved it in a rather unorthodox way, something I probably wouldn't recommend ANYONE but I'll write it anyway since maybe it will help someone who's in a hurry to get it done. Just remember this is a bad way of doing it.

My app basically consists of 4 buttons and a browserfield.

To display a spinning "load animation" I use alishaik786's tip (see his comments) of the custom PopupScreen triggered by a browserfieldlistener:

// BrowserFieldListener to catch when a page started loading and when it is finished
                BrowserFieldListener listener = new BrowserFieldListener() {

                            public void documentCreated(BrowserField browserField, ScriptEngine scriptEngine, Document document) throws Exception{
                                displayLoadAnimation(); 
                               // see method below
                            }           

                            public void documentLoaded(BrowserField browserField, Document document) throws Exception{
                                try{
                                    popUp.close();
                                }catch(IllegalStateException es){
                                    es.printStackTrace();
                                }
                            }
                        };

            // The method for showing the popup
            private void displayLoadAnimation(){

                    popUp = new LoadingPopupScreen();

                    UiApplication.getUiApplication().invokeLater(new Runnable() {
                        public void run() {
                            UiApplication.getUiApplication().pushScreen(popUp);
                        }
                    });
                }

Then in my custom PopupScreen I check where the user is clicking in "protected boolean touchEvent(TouchEvent event)" by checking event.getGlobalY() & event.getGlobalX() of the touch and comparing it to the positions of the buttons. If the user presses within the X&Y of a button then the popup screen is closed and I trigger the button being pressed.

As I said this is a bad way of doing it (many things need to be static), but it works if you want a quick and dirty sollution.

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