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...
views:
86answers:
1
+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
2009-09-25 07:39:12
I was wondering if I could animate using the CustomItem class and then inculde that CustomItem into the List.
Kevin Boyd
2009-09-25 07:44:52
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
2009-09-25 11:06:30
@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
2009-09-25 12:03:09
@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
2009-09-25 12:12:29
@Fostah: And how do I make a two frame Sprite object?...
Kevin Boyd
2009-09-25 12:28:42
The problem here is that you have no control on when the paint() method is called. This is implementation-specific.
Maurice Perry
2009-09-25 13:23:04
@Maurice: Isn't this the case also with the typical Canvas the callback paint() is called by the implementation.
Kevin Boyd
2009-09-25 14:10:17
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
2009-09-30 10:05:05