1 回答
TA贡献1条经验 获得超0个赞
对你的点击进行监听,当监听到按下的时候,停止图片的自动播放
.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
int action = event.getAction();
if (action == MotionEvent.ACTION_DOWN) {
mIsStop = true;
} else if (action == MotionEvent.ACTION_UP) {
mIsStop = false;
}
return false;
}
});
自动循环播放的时候,判断一下 if (!mIsStop)
private Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
switch (msg.what) {
case 3://大焦点图
if (adViewList != null && adViewList.size()>0) {
adCurrentItem = adCurrentItem % adViewList.size();
//点击图片时,自动切换变成暂停状态
if (!mIsStop) {
adCurrentItem++;
mViewPager.setCurrentItem(adCurrentItem % adViewList.size());
}
}
break;
}
}
};
- 1 回答
- 0 关注
- 1256 浏览
添加回答
举报