import android.content.Context;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
import com.youth.banner.Banner;
import com.youth.banner.BannerConfig;
import com.youth.banner.loader.ImageLoader;
import java.util.ArrayList;
import java.util.List;
要用4.4模拟器
public class MainActivity extends AppCompatActivity {

    private Banner banner;
    private List<String> list;
//创建数组放入图片
 private String arr[] = {"http://juheimg.oss-cn-hangzhou.aliyuncs.com/cookbook/t/0/24_429116.jpg",
            "http://juheimg.oss-cn-hangzhou.aliyuncs.com/cookbook/t/2/1576_403266.jpg",
            "http://juheimg.oss-cn-hangzhou.aliyuncs.com/cookbook/t/1/673_451750.jpg",
            "http://juheimg.oss-cn-hangzhou.aliyuncs.com/cookbook/t/1/132_224525.jpg"};

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        banner = (Banner) findViewById(R.id.ban);
        list=new ArrayList<>();
        for (String s:arr
             ) {
            list.add(s);
        }
        banner.setImageLoader(new image());
        banner.setImages(list);
        banner.setBannerStyle(BannerConfig.NUM_INDICATOR);
        banner.setDelayTime(3000);
        banner.start();
    }
    public class image extends ImageLoader{
        @Override
        public void displayImage(Context context, Object path, ImageView imageView) {
            Glide.with(context).load(path).into(imageView);
        }
    }


//需要导包:glide

//在bulid加

compile 'com.youth.banner:banner:1.4.9'


Banner轮播图(需要加的在后面 )


相关文章:

  • 2021-05-24
  • 2021-11-15
  • 2021-12-07
  • 2021-10-07
  • 2021-06-12
  • 2021-11-27
  • 2021-12-12
  • 2021-12-02
猜你喜欢
  • 2022-01-01
  • 2021-10-07
  • 2021-12-12
  • 2021-12-12
  • 2021-10-07
  • 2021-04-25
相关资源
相似解决方案