Hi,

    So I'm trying to write an android program to loop through my
pictures every 250 milliseconds (kind of like a very fast slide show).
What would be the best method to do this? I've noticed that sometimes
in the emulator some pictures are quite faster than the others (not an
exact 250 millisecond interval). Here's some snippet code that I'm
using.

private Handler testHandler = new Handler();
        private Runnable runnable = new Runnable()
        {
                public void run()
                {
                        updateImage();
                }
        };

private void updateImage()
    {
        if(mCounter == 7)
                mCounter = 0;
                mImageSwitcher.setImageResource(mImageIds[mCounter++]);
               //maybe there's a better way to cache these images or
something.
    }

where mImageIds is an array of drawable pics (R.drawable.pic1,
R.drawable.pic2, etc).

I was trying to start this with using a start button:

button_one.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                long time = SystemClock.uptimeMillis() + 1000; //adding 1
second for extra time
                for(int i = 0;i<7;++i)
                {
                        long runtime = time + i*300;
                        testHandler.postAtTime(runnable, runtime);
                }

Not sure if i'm on the right path, but if someone can help me figure
out why some pictures load faster than the others, that would be
great.

Thanks.

--~--~---------~--~----~------------~-------~--~----~
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