2

I'm trying to make an animation in my app which needs to stop after a given time. I can't use the animation list because I've tried to stop it but it doesn't stop or animates only once with android one shot option. I've then used the following code with the handler and tried to change the drawables with the handler delay. Please help me with this to make it animate and stop after delay.

final int k = 0;
for (int h = 0; h < 9; h++)
{
    final Handler handler = new Handler();
    handler.postDelayed(new Runnable() {

        @Override
        public void run() {
            // TODO Auto-generated method stub

            int Drw[] = { R.drawable.one, R.drawable.two, R.drawable.three, R.drawable.four,
                    R.drawable.five, R.drawable.six, R.drawable.seven, R.drawable.eight };

            ImageView nc = (ImageView) findViewById(R.id.imageView1);

            nc.setBackgroundResource(Drw[jlog(k)]);
        }

    }, 500);
}


private int jlog(int l)
{
    l++;
    return l;
}

This code doesn't animate the object but displays the object in one position.

Seraphim's
  • 12,559
  • 20
  • 88
  • 129

0 Answers0