将 Android 图库用作自动幻灯片

Using the Android Gallery as an automated slideshow(将 Android 图库用作自动幻灯片)

本文介绍了将 Android 图库用作自动幻灯片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我想为应用创建启动画面,并让画廊在计时器上旋转几张图片.谁能告诉我如何使用计时器为图库中的图像设置动画?

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?

推荐答案

一个简单的解决方案是

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

这篇关于将 Android 图库用作自动幻灯片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:将 Android 图库用作自动幻灯片

基础教程推荐