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使用
最新推荐文章于 2022-08-11 14:41:58 发布