[新手教程] 用Banner和 Glide实现自动轮播

第1步
      导入依赖

	implementation 'com.github.bumptech.glide:glide:4.9.0'
	implementation 'com.youth.banner:banner:1.4.9'
	![找到你的项目](https://img-blog.csdnimg.cn/20190415203546430.png)

双击 粘贴到里面
把上面的依赖粘贴进来
第2步
     先写布局

				<com.youth.banner.Banner
  				 android:id="@+id/bander"
		 		 android:layout_width="match_parent"
 				  android:layout_height="150dp"/>`

在Android studio找到如图的项目

		**第三步**
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			找控件,设置图像加载程序
				
				//设置图像加载程序
                banner.setImageLoader(new ImageLoader() {
                    @Override
                    public void displayImage(Context context, Object path, ImageView imageView) {
                        Bean2 path1 = (Bean2) path;
                        Glide.with(context).load(path1.getImageUrl()).into(imageView);
                    }
                });
                //设置照片
                //list数据类型为图片http://h.hiphotos.baidu.com/image/pic/item/a6efce1b9d16fdfad03ef192ba8f8c5494ee7b7f.jpg
                //如list.add("http://h.hiphotos.baidu.com/image/pic/item/a6efce1b9d16fdfad03ef192ba8f8c5494ee7b7f.jpg");
                banner.setImages(blist);
                //是否是自动轮播
                banner.isAutoPlay(true);
                //设置延迟时间
                banner.setDelayTime(2000);
                //开始轮播
                banner.start();

效果
在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值