Banner实现无限轮播Glide加载图片

//导入依赖

compile 'com.youth.banner:banner:1.4.9'
/记得加上网络权限
<uses-permission android:name="android.permission.INTERNET">uses-permission>
//主的Activity
public class MainActivity extends AppCompatActivity implements INewsVIEW {

    private Banner ban;
    private p p;
    List list2=new ArrayList();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //加载控件
        ban = (Banner)findViewById(R.id.ban);
        p = new p(MainActivity.this, this);
        p.lun(1);

    }


    @Override
    public void success(List list2) {
        ban.setImageLoader(new ImgApp());//引用ImgApp,加载里面的东西
        ban.setImages(list2);
        ban.isAutoPlay(true);
        ban.setDelayTime(2000);
        ban.start();
    }
    @Override
    public void failed(String tag, String e) {

    }
}
//加载图片的类 
  
public class ImgApp extends ImageLoader {

   @Override
    public void displayImage(Context context, Object path, ImageView imageView) {
       Glide.with(context).load(path).into(imageView);//Glide加载图片
    }
}


你可能感兴趣的:(Banner实现无限轮播Glide加载图片)