@Override
public Object instantiateItem(ViewGroup container, int position) {
View view = View.inflate(context, R.layout.pic_item, null);
ImageView imageview=(ImageView) view.findViewById(R.id.picimage);
imageview.setImageResource(picList.get(position%picList.size()));
imageview.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
handler.removeCallbacksAndMessages(null);
break;
case MotionEvent.ACTION_UP:
handler.sendEmptyMessageDelayed(0, 2000);
break;
case MotionEvent.ACTION_CANCEL:
handler.sendEmptyMessageDelayed(0, 2000);
break;
default:
break;
}
return true;
}
});
container.addView(view);
return view;
}
viewpager轮播图片设置OntounchListener
最新推荐文章于 2021-06-02 21:18:12 发布