2010-12-08 65 views
3

我正在为我的应用程序制作一个画廊并滑动它,我选择了不同的背景图像。如何在imageSwitcher图像更改(Android)上设置延迟

gallery.setOnItemSelectedListener(new Gallery.OnItemSelectedListener() { 
    @Override 
    public void onItemSelected(AdapterView<?> arg0, View arg1, 
    int arg2, long arg3) { 

    imageSwitcher.setImageResource(imm[arg2]); 

这个想法正常工作,但滑动效果不流畅。 我的想法是设置延迟,设置:

imageSwitcher.setImageResource(imm[arg2]); 

只有经过200ms的左右... 是这样的可能吗?

谢谢:) 马尔科

回答

1

您可以使用Timer和TimerTask类调度操作发生的每200ms

喜欢的东西

Timer scrollTimer = new Timer(); 
scrollTimer.schedule(
    new TimerTask(){ 
    @Override 
    public void run(){ 
     runOnUiThread(Call the method to do ur work); 
    } 
}, 
0,200);