2010-07-30 60 views

回答

5

一個簡單的解決辦法是

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