使用Android画廊作为自动幻灯片[英] Using the Android Gallery as an automated slideshow

本文是小编为大家收集整理的关于使用Android画廊作为自动幻灯片的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

嗨,我想为应用程序创建一个飞溅屏幕,并在计时器上旋转几张图像.谁能告诉我如何使用计时器在画廊中对图像进行动画?

推荐答案

一个简单的解决方案将是

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://www.itbaoku.cn/post/102488.html

问题描述

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?

推荐答案

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