zgz345

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

final Handler autoGalleryHandler = new Handler() {
public void handleMessage(Message message) {
super.handleMessage(message);
switch (message.what) {
case 1:
galleryFlow.setSelection(message.getData().getInt("pos"));

break;
}
}
};

Timer autoGallery = new Timer();
autoGallery.schedule(new TimerTask() {
int gallerypisition = 0;
@Override
public void run() {
if (gallerypisition < adapter.getCount() - 1) {
gallerypisition = gallerypisition + 1;
} else {
gallerypisition = 0;
}

Message msg = new Message();
Bundle date = new Bundle();// 存放数据
date.putInt("pos", gallerypisition);
msg.setData(date);
msg.what = 1;//消息标识
autoGalleryHandler.sendMessage(msg);
}
}, 0, 3000);//5秒后,每隔5秒执行信息发送

posted on 2012-05-23 17:44  zonyZhang  阅读(268)  评论(0编辑  收藏  举报