Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8217039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:20:34+00:00 2026-06-07T12:20:34+00:00

I am calling this class which is PopupScreen . public class Custom_LoadingScreen extends PopupScreen

  • 0

I am calling this class which is PopupScreen.

public class Custom_LoadingScreen extends PopupScreen {
private VerticalFieldManager vfm;
private Util_AnimateGifField anmtFldCycle = null;
private GIFEncodedImage gifImgCycle;

public Custom_LoadingScreen() {
    super(new VerticalFieldManager());
    Background bg = BackgroundFactory.createSolidTransparentBackground(
            Color.BLACK, 190);
    setBackground(bg);
    setBorder(BorderFactory.createSimpleBorder(new XYEdges(),
            Border.STYLE_TRANSPARENT));

    gifImgCycle = (GIFEncodedImage) GIFEncodedImage
            .getEncodedImageResource("LoadingSpinner.gif");
    anmtFldCycle = new Util_AnimateGifField(gifImgCycle,
            Field.FIELD_HCENTER);

    vfm = new VerticalFieldManager(USE_ALL_WIDTH) {
        protected void sublayout(int maxWidth, int maxHeight) {
            super.sublayout(Display.getWidth(), Display.getHeight());
            setExtent(Display.getWidth(), Display.getHeight());
        }
    };
    int padding = (Display.getHeight() - 16) / 2;
    if (padding > 0) {
        anmtFldCycle.setPadding(padding, 0, 0, 0);
    }
    vfm.add(anmtFldCycle);
    add(vfm);
}

//public void Popupscreen() {
    //Main.getUiApplication().popScreen(this);
//}

public boolean keyDown(int keycode, int status) {
    if (Keypad.key(keycode) == Keypad.KEY_ESCAPE) {
        Main.getUiApplication().popScreen(this);
        return true;
    }
    return super.keyDown(keycode, status);
}
}

In a button, I pushed it before goes to next screen.

financebtn = new Custom_ButtonField(finance, financeactive,
            financeactive) {
        protected boolean navigationClick(int status, int time) {
            Main.getUiApplication().pushScreen(new Custom_LoadingScreen());
            Main.getUiApplication().invokeLater(new Runnable() {
                public void run() {
                //  Main.getUiApplication().popScreen();
                    Main.getUiApplication().pushScreen(
                            new Main_NewsDetail());
                }

            }, 1 * 1000, false);

            return true;
        }
    };
    add(financebtn);

The result give me Uncaught:ClassCastException. I can call another class which is similar to custom_loadingscreen also popupscreen. It work fine.

I also tried call this class in another button yet still same problem.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T12:20:35+00:00Added an answer on June 7, 2026 at 12:20 pm

    If you take a look at your Custom_LoadingScreen code, there’s only one place where you are doing a cast:

    gifImgCycle = (GIFEncodedImage) GIFEncodedImage
            .getEncodedImageResource("LoadingSpinner.gif");
    

    So, that’s a good place to start looking. If you Google for “BlackBerry GIFEncodedImage ClassCastException”, you’ll find this thread:

    http://supportforums.blackberry.com/t5/Java-Development/GIFEncodedImage-in-BlackBerry-OS7/td-p/1228959

    The problem is that, for optimization, BlackBerry likes to convert images to the PNG format, which most smartphones work best with. So, what’s happening here is that your GIF image is actually being converted to a PNG image. Therefore, when you call the getEncodedImageResource() method, the object you are getting back may actually be of type PNGEncodedImage, not GIFEncodedImage, and you get the exception. Sneaky, huh?

    You can solve it a few ways.

    1. In the Blackberry_App_Descriptor.xml file, you can uncheck the setting that specifies that images are converted to PNG (Build tab -> Convert image files to png)
    2. You can trick the build system by renaming your GIF file to something like LoadingSpinner.agif. The toolset doesn’t recognize the .agif extension, and therefore won’t try to convert it. If you do this, of course, remember to change the filename in your Java code, too, when loading it.
    3. You can change the code to use PNGEncodedImage, or test the object like this:
    EncodedImage img = EncodedImage.getEncodedImageResource("LoadingSpinner.gif");
    if (img instanceof GIFEncodedImage) {
       // cast to GIFEncodedImage
    } else if (img instanceof PNGEncodedImage) {
       // cast to PNGEncodedImage
    }
    

    Number (1) will lose the non-PNG to PNG conversion optimization for all your non-PNG images, not just this one.

    Number (2) does look a little ugly. The benefit of doing this, though, is that you can disable this behaviour for just this one image. If most of your images are not PNG images, it might be valuable to let BlackBerry optimize for you, for the other images. But, maybe this one needs to be a GIF. So, #2 lets you handle this one as a special case.

    I’m just guessing that this image might be an animated GIF? Is that right? If so, you probably want to keep it as a GIF, so you won’t want to do number (3), which lets it be converted to a PNG, and uses it as such.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The browser does this by calling public void emulateShiftHeld() method on the WebView which
all i this is my code in notification class which i am calling after
I have a class whitch extends JPanel: public class ButtonPanel extends JPanel { private
I have one class which is calling other classes, this class is my main.
I need this for calling a C function from Java class (JNI) and I
I'm using a Class Library exporting a function via COM. When calling this function
I have some code which use 'this' pointer of class which calls this code.
This is quite hard to explain. I have a class which should support the
A have a C# class which simplifies the handling of global hot keys. This
I am calling this zip_threading class in another class. string a = zip_threading(?,?) but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.