使用 Blackberry JAVA SDK 6.0 活动指示器 UI 元素加载屏幕轮

发布于 2024-11-30 16:39:49 字数 1456 浏览 0 评论 0原文

在我的项目中,我想在发生 http 连接时显示带有滚轮图像(可能带有 .gif 文件)的加载屏幕。

我的代码如下。它扩展了一个类,该类扩展了 MainScreen。当用户单击登录按钮时,我显示此屏幕。

public class MSWheelScreen extends MSScreen{



//Constructor
public MSWheelScreen(){
    super();

    add(new SeparatorField());
    add(new LabelField("Loading...", Field.FIELD_HCENTER));
    add(new SeparatorField());
    add(new LabelField());


    ActivityIndicatorView myview = new ActivityIndicatorView(Field.USE_ALL_WIDTH);
    ActivityIndicatorModel mymodel = new ActivityIndicatorModel();
    ActivityIndicatorController mycontroller = new ActivityIndicatorController();

    myview.setController(mycontroller);
    myview.setModel(mymodel);

    mycontroller.setModel(mymodel);
    mycontroller.setView(myview);

    mymodel.setController(mycontroller);




    Bitmap mybitmap = Bitmap.getBitmapResource("img/wheel.gif");

    myview.createActivityImageField(mybitmap, 5, Field.FIELD_HCENTER);
    add(myview);

}



}

反正;我的问题是,我无法按我想要的方式显示车轮图像。我只能看到轮子的一部分,当我在浏览器中打开它时,我无法看到整个 .gif 文件。所以我想调整我在加载屏幕上添加的 .gif 文件。我想知道一些内置方法,我可以将它们与活动指示器 UI 元素一起使用来调整我的 gif。

我的示例运行屏幕截图的链接:

http://imageshack.us/photo/ my-images/191/9800j.jpg/

原始 gif 的链接。

http://imageshack.us/photo/my-images/810/ajaxloaderw。动图/

In my project,I want to show a loading screen with a rolling wheel image(possibly with a .gif file) while my http connection occured.

My code is below. It extends a class which extends MainScreen. I show this screen when the user clicked login button.

public class MSWheelScreen extends MSScreen{



//Constructor
public MSWheelScreen(){
    super();

    add(new SeparatorField());
    add(new LabelField("Loading...", Field.FIELD_HCENTER));
    add(new SeparatorField());
    add(new LabelField());


    ActivityIndicatorView myview = new ActivityIndicatorView(Field.USE_ALL_WIDTH);
    ActivityIndicatorModel mymodel = new ActivityIndicatorModel();
    ActivityIndicatorController mycontroller = new ActivityIndicatorController();

    myview.setController(mycontroller);
    myview.setModel(mymodel);

    mycontroller.setModel(mymodel);
    mycontroller.setView(myview);

    mymodel.setController(mycontroller);




    Bitmap mybitmap = Bitmap.getBitmapResource("img/wheel.gif");

    myview.createActivityImageField(mybitmap, 5, Field.FIELD_HCENTER);
    add(myview);

}



}

Anyway; my problem is that, I cant show the wheel image as i wanted. I can only see the part of the wheel, i am not able to see the whole .gif file as i open it in a browser. So i want to adjust the .gif file that i have added on the loading screen. I want to know some built in methods that i can use with activity indicator UI elements to adjust my gif.

The link for my sample run screenshot:

http://imageshack.us/photo/my-images/191/9800j.jpg/

The link for original gif.

http://imageshack.us/photo/my-images/810/ajaxloaderw.gif/

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

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

发布评论

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

评论(1

私藏温柔 2024-12-07 16:39:49

使用 .gif 实现加载屏幕很困难,因为它需要多一个处理 .gif 图像的线程
所以我总是在黑莓中实现加载屏幕,如下所示:

这是加载屏幕的简单代码....

                HorizontalFieldManager popHF = new HorizontalFieldManager();
                popHF.add(new CustomLabelField("Pls wait..."));
                final PopupScreen waitScreen = new PopupScreen(popHF);
                new Thread()
                {
                    public void run() 
                    {

                        synchronized (UiApplication.getEventLock()) 
                        {
                            UiApplication.getUiApplication().pushScreen(waitScreen);
                        }
                       //Here Some Network Call 

                       synchronized (UiApplication.getEventLock()) 
                        {
                            UiApplication.getUiApplication().popScreen(waitScreen);
                        }
                     }
                 }.start();

It is difficult to implement loading screen with .gif bcz it required one more thread that handle .gif image
So i always implement Loading screen in blackberry like this :

This is simple code for loading screen ....

                HorizontalFieldManager popHF = new HorizontalFieldManager();
                popHF.add(new CustomLabelField("Pls wait..."));
                final PopupScreen waitScreen = new PopupScreen(popHF);
                new Thread()
                {
                    public void run() 
                    {

                        synchronized (UiApplication.getEventLock()) 
                        {
                            UiApplication.getUiApplication().pushScreen(waitScreen);
                        }
                       //Here Some Network Call 

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