Using the Android Gallery as an automated slideshow

放肆的年华 提交于 2019-11-30 19:54:10

问题


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 Gallery?


回答1:


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.
    }


来源:https://stackoverflow.com/questions/3373536/using-the-android-gallery-as-an-automated-slideshow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!