1. 程式人生 > >Fresco與banner結合展示無限輪播

Fresco與banner結合展示無限輪播

compile 'com.youth.banner:banner:1.4.10'
compile 'com.facebook.fresco:fresco:0.11.0'
compile 'com.facebook.fresco:imagepipeline-okhttp3:0.11.0'



<com.youth.banner.Bannerandroid:id="@+id/ban"android:layout_width="match_parent"android:layout_height="150dp" />


public class HomePage extends Fragment { Banner ban
;
String[] urls = {
        "https://image.yunifang.com/yunifang/images/goods/2076/goods_img/170930212555714134276722977.jpg",
        "https://image.yunifang.com/yunifang/images/goods/492/goods_img/171011191068814258195256706.jpg",
        "https://image.yunifang.com/yunifang/images/goods/temp/17051609265319705925918251.jpg",
        "https://image.yunifang.com/yunifang/images/goods/temp/17101119312216937168845205.jpg"
, "https://image.yunifang.com/yunifang/images/goods/temp/171011162655217457875119759.jpg" };
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.layout_homepage, null);
    ban 
= view.findViewById(R.id.ban); return view; }
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    manager = new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false);
    rv.setLayoutManager(manager);

    ban.setImageLoader(new ImageLoader() {
        @Override
public void displayImage(Context context, Object path, ImageView imageView) {

            imageView.setImageURI(Uri.parse((String) path));

           // com.nostra13.universalimageloader.core.ImageLoader.getInstance().displayImage((String) path, imageView);
}

        @Override
public ImageView createImageView(Context context) {
            SimpleDraweeView simpleDraweeView = new SimpleDraweeView(context);
            return simpleDraweeView;
        }
    });
    ban.setImages(Arrays.asList(urls));
    ban.start();
  }
}