嗨,我想为一个应用程序创建一个SplashScreen,并让一个库在计时器上旋转几个图像。有谁能给我演示一下如何用定时器来给画廊里的图片制作动画吗?
最佳答案
一个简单的解决方案是
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.
}