@Override public boolean handleMessage(Message msg) { if (mViewPager != null) { mViewPager.setCurrentItem(mViewPager.getCurrentItem() + 1); handler.sendEmptyMessageDelayed(0, mCycleDelayed); } return false; }
/** * 加载显示的数据 网络图片资源及标题 * * @param list 数据 * @param callBack 如何加载图片及显示的回调方法 not null */ public void loadData(List<ImageInfo> list, LoadImageCallBack callBack) { data = list; mCount = list.size(); initIndication(); if (callBack == null) { new IllegalArgumentException("LoadImageCallBack 回调函数不能为空!"); } mLoadImageCallBack = callBack; mViewPager.setAdapter(new ImageCycleAdapter()); // 最大值中间 的第一个 mViewPager.setCurrentItem(Integer.MAX_VALUE / 2 - ((Integer.MAX_VALUE / 2) % mCount)); }
/** * 初始化view控件 * * @author 代凯男 */ private void initView() { View.inflate(mContext, R.layout.view_image_cycle, this); FrameLayout fl_image_cycle = (FrameLayout) findViewById(R.id.fl_image_cycle); mViewPager = new ImageCycleViewPager(mContext); mViewPager.setLayoutParams( new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); fl_image_cycle.addView(mViewPager); mViewPager.setOnPageChangeListener(new ImageCyclePageChangeListener()); mIndicationGroup = (LinearLayout) findViewById(R.id.ll_indication_group); mText = (TextView) findViewById(R.id.tv_text); }