Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Trusted Contributor
Posts: 167
Registered: ‎06-30-2011
My Device: n/a
My Carrier: Koodo

How to use the AnimatedGIFField class from knowledge base? ie. manipulation

Hey guys, I've got the gif up and running using this article: http://supportforums.blackberry.com/t5/Java-Development/Display-an-animated-GIF/ta-p/445014 


After a lot of searching though, I can't really seem to find out how to manipulate the gif. I know how to position it, but how can I make it only run through once and disappear after its done the cycle? Any links or guides to this area would be very helpful, I want to heavily use GIFs in the future. Thanks!

Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: How to use the AnimatedGIFField class from knowledge base? ie. manipulation

You can do all kinds of checks in paint and schedule some action via invokeLater when you reach frame #0 for the second time. For example, you might stop the animation thread, set some "do not paint" flag and ask for a layout via updateLayout. In your layout, check that "do not paint" flag and set extent to (0, 0) if true.


You'll need two boolean flags for this:

- firstTime, initially true and reset to false after the first check in paint. If already false and frame index is 0, stop animation;

- doNotPaint, initially false and checked both in layout and paint. If true, set extent to (0, 0) in layout and return immediately in paint.


I'm sure there must be other ways to achieve something similar - this is just me brainstorming the issue...

please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!