I get a ClassCastException when trying to animate a GifImage in BlackBerry. I tried many ways, but all cause that exception. I referred to the BlackBerry knowledgecenter article “Display An Animated GIF” and I tried the following code in my mainscreen. I also tried using @swati’s code from the “Animated GIF” blog post. What is my mistake?
GIFEncodedImage bitmapImage=(GIFEncodedImage)GIFEncodedImage.getEncodedImageResource("CuteCapLa4.gif"); //**Getting Exception at this line**
AnimatedGIFField image_field=new AnimatedGIFField(bitmapImage);
add(image_field);
As described here:
rapchas option to convert image files to png format. However it keeps name and extension of original file. In this case you lose ability to animate as well as you getClassCastException.If you’re using eclipse you could check this option in the Application Descriptor XML file under the “Build” submenu.