初始化数据,填充到 ~~~ ImageCycleView mAdView=(ImageCycleView) view.findViewById(R.id.ad_view); blist = (ArrayList<HashMap<String, Object>>) msg.obj; for (int i = 0; i < blist.size(); i++) { ADInfo info = new ADInfo();//图片路径,url路径实体类 info.setUrl(blist.get(i).get("ad_file").toString()); info.setContent(blist.get(i).get("ad_url").toString()); infos.add(info); } mAdView.setImageResources(infos); ~~~ 装填图片数据 /** * 装填图片数据 * * @param imageUrlList * @param imageCycleViewListener */ public void setImageResources(ArrayList<ADInfo> infoList) { // 清除所有子视图 mGroup.removeAllViews(); // 图片广告数量 final int imageCount = infoList.size(); mImageViews = new ImageView[imageCount]; for (int i = 0; i < imageCount; i++) { mImageView = new ImageView(mContext); LinearLayout.LayoutParams layout = new LinearLayout.LayoutParams(24, 24); layout.setMargins(3, 0, 3, 0); mImageView.setLayoutParams(layout); // mImageView.setPadding(imagePadding, imagePadding, imagePadding, // imagePadding); mImageViews[i] = mImageView; if (i == 0) { mImageViews[i] .setBackgroundResource(R.drawable.ic_evaluate_button_pressed); } else { mImageViews[i] .setBackgroundResource(R.drawable.ic_evaluate_button_normal); } mGroup.addView(mImageViews[i]); } mAdvAdapter = new ImageCycleAdapter(mContext, infoList); mBannerPager.setAdapter(mAdvAdapter); startImageTimerTask(); } 开始图片滚动任务 /** * 开始图片滚动任务 */ private void startImageTimerTask() { stopImageTimerTask(); // 图片每3秒滚动一次 mHandler.postDelayed(mImageTimerTask, 3000); }