Using the Android Gallery as an automated slideshow

前端 未结 1 1728
太阳男子
太阳男子 2021-01-07 02:13

Hi I want to create a splashscreen for an app, and have a gallery rotate several images on a timer. Can anyone show me how I could use a timer to animate the images in a Gal

相关标签:
1条回答
  • 2021-01-07 02:54

    an easy solution would be

    private int PicPosition;
    private Handler handler = new Handler();
    

    ... ... ...

    private Runnable runnable = new Runnable() {
        public void run() {
            myslideshow();
            handler.postDelayed(this, 1000);\\execute every second.
        }
    };
    
        private void myslideshow()
        {
                        PicPosition = gallery.getSelectedItemPosition() +1;             
                        if (PicPosition >=  Pictures.size())            
                        PicPosition =  gallery.getSelectedItemPosition(); //stop 
                                        else
                        gallery.setSelection(PicPosition);//move to the next gallery element.
        }
    
    0 讨论(0)
提交回复
热议问题