views:

86

answers:

1

How could I implement animation in Java ME?
I would want to achieve the following, I want to make a List the items in the List are animated icons with some related text description...
I would like to animate all these Icons simultaneously...

+1  A: 

I'm afraid you cannot do that with the standard List component. You will need to implement your own or use a third-party component.

UPDATE

I was wrong actually: you can use a CustomItem and have a timer call repaint() every x milliseconds.

Maurice Perry
I was wondering if I could animate using the CustomItem class and then inculde that CustomItem into the List.
Kevin Boyd
You can do that, however I am not sure if the implementation will call the paint() method defined by you. I have not tried that though
Ram
@Ram: abstract class CustomItem has a method "abstract void paint(Graphics g, int w, int h)", so if I subclass CustomItem and override "paint" shouldn't it be called by the implementation to render the CustomItem?
Kevin Boyd
@Kevin Boyd That reasoning makes sense. I've never tried it either, but it shouldn't be too hard, or too much of a waste of time if it doesn't work, for you to give it a shot. Just create a two frame Sprite object and see what happens. Definitely let us know how it works out :)
Fostah
@Fostah: And how do I make a two frame Sprite object?...
Kevin Boyd
The problem here is that you have no control on when the paint() method is called. This is implementation-specific.
Maurice Perry
@Maurice: Isn't this the case also with the typical Canvas the callback paint() is called by the implementation.
Kevin Boyd
No paint cannot or rather should not be invoked directly in an application however, you can call repaint() to have the Canvas object repainted. However in the case of a CustomItem, I am not sure if you can call the repaint as you would call it on a Canvas object. And as Fostah suggested you could try out a Sprite that contains 2 frames. Do let us know how it works out :)
Ram