bannerOper();
}
//添加头部轮播
private void bannerOper() {
//添加头部
View head = View.inflate(getActivity(), R.layout.layout_head, null);
ListView refreshableView = pullist.getRefreshableView();
//初始化控件
AbsListView.LayoutParams params = new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT, 300);
head.setLayoutParams(params);
refreshableView.addHeaderView(head);
img_viewpager = head.findViewById(R.id.img_viewpager);
bannerCallBack = new BannerCallBack();
httputils.getserverData(bannerUrl,bannerCallBack);
}
class BannerCallBack implements HttpUtils.HttpUtilsCallback{
@Override
public void onSuccess(String result) {
Gson gson = new Gson();
BannerBean bannerBean = gson.fromJson(result, BannerBean.class);
for (BannerBean.DataBean dataBean:bannerBean.getData()){
ImageView imageView = new ImageView(getActivity());
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
ImageLoader.getInstance().displayImage(dataBean.getImg(), imageView);
imageViews.add(imageView);
}
PageAdapter pagerAdapter = new PageAdapter(imageViews);
img_viewpager.setAdapter(pagerAdapter);
handler.sendEmptyMessageDelayed(0,1000);
}
@Override
public void onError(String errorMsg) {
Log.i("xxx",errorMsg);
}
}