android定时滚动
16lz
2022-04-03
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秒执行信息发送
更多相关文章
- Android内核的根文件系统
- 源码剖析: Notification的发送
- android 客户端 smtp 协议发送数据
- android 定时发送短信
- Android(安卓)使用广播(BroadcastReceiver)传递数据
- android发送QQ邮件(带附件)
- android群发短信时判断短信是否发送成功
- android 微信登录
- android下联网