【问题标题】:Using the Android Gallery as an automated slideshow将 Android 图库用作自动幻灯片
【发布时间】:2011-03-23 08:37:21
【问题描述】:

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

【问题讨论】:

    标签: java android timer components gallery


    【解决方案1】:

    一个简单的解决方案是

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

    【讨论】:

      猜你喜欢
      • 2012-11-27
      • 2015-04-21
      • 1970-01-01
      • 2017-10-05
      • 1970-01-01
      • 1970-01-01
      • 2012-07-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多