0

I m storing image from server in an Bitmap arrayList, then using a thread which waits 3 second, switching the image.Suppose the size of arraylist is 3.then after switching 3 image one after another, its waiting another 3sec but now there is no image. and again its circulating from 0. I m not getting why this extra 3sec its waiting.

Code for the tread is..

ImageSwitcher dailywear;
ArrayList<Bitmap> bitmapDailywear = new ArrayList<Bitmap>();
dailyWear.setImageDrawable(new BitmapDrawable(bitmapDailyWear.get(0)));

final Handler handler = new Handler();

    final Runnable r = new Runnable() {
        int i = 1;

        public void run() {


            dailyWear.setImageDrawable(new BitmapDrawable(bitmapDailyWear.get(i)));
            i++;
            if (i == bitmapDailyWear.size())
                i = 0;

            handler.postDelayed(this, 3000);

        }
    };

    handler.postDelayed(r, 3000);
Anoop M Maddasseri
  • 10,213
  • 3
  • 52
  • 73
Rahul
  • 395
  • 5
  • 20
  • please explain your question .... where r you getting this extra 3 sec – kumar kundan Aug 03 '15 at 10:37
  • @kumarkundan - i am loading all image in an bitmap arraylist, when i m putting the thread, then image is switching one after another till the size of the arraylist. after loading the image of last index of the arraylist , then its waiting for 3 sec and no image are there at that time (this is the extra 3sec) after this 3 sec is passing its again starts switching , from the array lindex 0. – Rahul Aug 03 '15 at 10:44

0 Answers0