The colors are wrong because you are most likely not updating your Paint
object correctly. As for the animation, it seems like you are simply using a
sleep() inside the drawing code right? If you do, it won't work. A sleep()
will block the rendering thread until it's done. Furthermore, Android uses a
double buffer model so everything that you drawn in a frame appears at the
same time when the frame is done drawing. Your code worked in your Java
applets because AWT does NOT use double buffering by default.

On Sat, May 14, 2011 at 6:25 PM, Heuristic <[email protected]> wrote:

> I write an Android Java program to "animate" the moving of Tower of
> Hanoi.
> The drawing does not show in steps I expected, instead it shows in a
> chunk at the end of the drawing. Why?
> Also, I use BLUE color to "erase" the discs moved, then use BLACK
> color to draw the missing stick portion. BUT, it does not use the BLUE
> color at all, instead it uses BLACK.
> It does work for the RED color that I used to paint the discs. Then,
> why not the BLUE?  I painted the BLUE first (to "erase the disc moved,
> but it also erased portion of the stick), then BLACK (to recover the
> missing stick portion), then RED (the disc that's moved to the other
> stick).
> The scenario can been seen in my personal website -
> 1. I set the disc number to be 5.
> http://homepage8.seed.net.tw/web@3/heuristic/TOH_Set051411001.JPG
> 2. Then, I start the moving. (I used the sleep timer so that it won't
> move too fast.)
> http://homepage8.seed.net.tw/web@3/heuristic/TOH_Start051411001.JPG
> 3. It ends up with the BLACK piles of the discs on the two other
> sticks as shown on the following URL:
> http://homepage8.seed.net.tw/web@3/heuristic/TOH_End051411001.JPG
>
> I wrote this Java program long time ago using Java Applet. Now, I just
> changed the interface to be Android GUI/API interface.
> The old program works fine on my website (in fact, in my all
> showoffs.) -
> http://homepage8.seed.net.tw/web@3/heuristic/tohjava.html
>
> This program was developed on Android 2.1-updated. I just ported to
> 3.0, it shows the first time, then halts there. I haven't got time to
> figure out.
>
> This is a very good educational material - to teach Math, Java,
> Computer Sciences, etc.
> Hope experienced Android guy can share experience here. This is a
> little bit like the "flush" in some i/o problem. Sometimes, if you
> don't flush, there is no output. So, why Android does not show the
> drawing out right away, instead it waits until the end of the drawing.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>



-- 
Romain Guy
Android framework engineer
[email protected]

Note: please don't send private questions to me, as I don't have time to
provide private support.  All such questions should be posted on public
forums, where I and others can see and answer them

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to