Intent mIntent=new Intent(mActivity, LunbotuActivity.class);
mActivity.startActivity(mIntent);
package com.jiawabang.ui.adapter;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.support.v4.view.PagerAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import com.jiawabang.Model.ArticleModel;
import com.jiawabang.R;
import com.jiawabang.ui.activity.LunbotuActivity;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.assist.ImageScaleType;
import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer;
import java.util.List;
/**
* Created by jiawayun on 2016/9/8.
*/
public class ViewPagerHomeFragmentAdapter extends PagerAdapter {
private ListmHomeBannerEntities;
private Activity mActivity;
private LayoutInflater mLayoutInflater;
private DisplayImageOptions mOptions;
public ViewPagerHomeFragmentAdapter(ListmHomeBannerEntities, Activity mActivity) {
this.mHomeBannerEntities = mHomeBannerEntities;
this.mActivity = mActivity;
this.mLayoutInflater = mActivity.getLayoutInflater();
mOptions = new DisplayImageOptions.Builder()
.showImageForEmptyUri(R.drawable.product_loading)
.showImageOnFail(R.drawable.product_loading)
.showImageOnLoading(R.drawable.product_loading)
.resetViewBeforeLoading(true)
.cacheOnDisk(true)
.imageScaleType(ImageScaleType.EXACTLY)
.bitmapConfig(Bitmap.Config.RGB_565)
.considerExifParams(false)
.displayer(new FadeInBitmapDisplayer(300))
.build();
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
ImageView mImageView = (ImageView) mLayoutInflater.inflate(R.layout.item_viewpager_homefragment, container, false);
mImageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View mView) {
Intent mIntent=new Intent(mActivity, LunbotuActivity.class);
mActivity.startActivity(mIntent);
}
});
container.addView(mImageView);
// Log.e("108", "run:---------> "+ mHomeBannerEntities.get(position % mHomeBannerEntities.size()).picurl);
//500轮播完了会报错,ArithmeticException算数异常,分母是0,可改为无穷大
ImageLoader.getInstance().displayImage("http://dev.jiawabang.com/cofco-fileserver/"+mHomeBannerEntities.get(position % mHomeBannerEntities.size()).picurl, mImageView, mOptions);
return mImageView;
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
container.removeView((View) object);
}
@Override
public int getCount() {
return Integer.MAX_VALUE;
}
@Override
public boolean isViewFromObject(View view, Object object) {
return view == object;
}
}