Xbanner使用


   implementation 'com.github.xiaohaibin:XBanner:1.6.1'

   final List<String> list = new ArrayList<>();
        for (int i=0;i<jsonArray.length();i++){
            try {
                JSONObject jsonObject = jsonArray.getJSONObject(i);
                String imageUrl = jsonObject.getString("imageUrl");
                list.add(imageUrl);
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
        Toast.makeText(getContext(),""+list.size(),Toast.LENGTH_LONG).show();
        //这个setData必须在loadImage上边
        home_xbanner.setData(list,null);
        home_xbanner.loadImage(new XBanner.XBannerAdapter() {
            @Override
            public void loadBanner(XBanner banner, Object model, View view, int position) {
                Glide.with(getContext()).load(list.get(position)).into((ImageView) view);
            }
        });

            <com.stx.xhb.xbanner.XBanner
                android:id="@+id/home_xbanner"
                android:layout_width="match_parent"
                android:layout_height="200dp"
                app:isClipChildrenMode="true"></com.stx.xhb.xbanner.XBanner>

你可能感兴趣的:(Xbanner使用)