android - How to load images in an ImageSwitcher from server? -


i m trying load images in image switcher http server. didnot find function setimagebitmap. tried using setimageuri() , not getting loaded. tring switch image after every 3 sec. code. when m running codes image not getting loaded. , app getting crased.

 string arr[]={"http://192.168.1.7/photos/dummy/1.jpg","http://192.168.1.7/photos/dummy/2.jpg","http://192.168.1.7/photos/dummy/3.jpg"}    dailywear = (imageswitcher) getactivity().findviewbyid(r.id.imagedailywear); dailywear.setfactory(new viewswitcher.viewfactory() {         @override         public view makeview() {             imageview myview = new imageview(getactivity());             myview.setscaletype(imageview.scaletype.fit_xy);             myview.setlayoutparams(new imageswitcher.layoutparams(relativelayout.layoutparams.match_parent, relativelayout.layoutparams.match_parent));             return myview;         }     });     dailywear.setinanimation(animationutils.loadanimation(getactivity(), android.r.anim.slide_in_left));     dailywear.setoutanimation(animationutils.loadanimation(getactivity(), android.r.anim.slide_out_right));   final handler handler = new handler();     final runnable r = new runnable() {          int i=0;         public void run() {             weddingwear.setimageuri(uri.parse(arr[i));              i++;             if (i >= arr.length()-1)                 = 0;              handler.postdelayed(this, 3000);         }     };      handler.postdelayed(r, 1000); 

what can first these images , store in arraylist of bitmap can switch these images

private context mcontext; private int index = 0; private final int interval = 3000; private final int duration=1500;     public void animate_images_in_top_view_after_every_three_seconds(         imageswitcher imageswitcher, final arraylist<bitmap> _images_list) {      android.view.animation.animation aniin = animationutils.loadanimation(mcontext,             android.r.anim.fade_in);     aniin.setduration(duration);     android.view.animation.animation aniout = animationutils.loadanimation(mcontext,             android.r.anim.fade_out);     aniout.setduration(duration);      final imageswitcher _imageswitcher = imageswitcher;     _imageswitcher.setinanimation(aniin);     _imageswitcher.setoutanimation(aniout);     _imageswitcher.setfactory((android.widget.viewswitcher.viewfactory) mcontext);     _imageswitcher.setimagedrawable(new bitmapdrawable(_images_list.get(index)));     final handler handler = new handler();     runnable runnable = new runnable() {          @override         public void run() {                  index++;                 index = index % _images_list.size();           //      log.d("intro screen", "change image " + index);                 _imageswitcher.setimagedrawable(new bitmapdrawable(_images_list.get(index)));                 handler.postdelayed(this, interval);          }     };     handler.postdelayed(runnable, interval); } 

and using fade in , out animation can set own need.


Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -