轮播图;list显示;Adapter

轮播图;list显示;AdapterpublicclassFrag01extendsFragmentimplementsShowView{privateXBannerbanner;privateXRecyclerViewrecyclerView;privateShowPresenterpresenter;privateStringPicUrl=“http://172.17.8.100/sma…

轮播图;list显示;Adapter"

public class Frag01 extends Fragment implements ShowView {

private XBanner banner;
private XRecyclerView recyclerView;
private ShowPresenter presenter;
private String PicUrl = “http://172.17.8.100/small/commodity/v1/bannerShow”;
private String ShowUrl = “http://172.17.8.100/small/commodity/v1/commodityList”;
private RecyclerAdapter adapter;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

View view = inflater.inflate(R.layout.frag01_item,container, false);
banner = (XBanner) view.findViewById(R.id.banner);
recyclerView = (XRecyclerView) view.findViewById(R.id.recycler);
presenter = new ShowPresenter(new ShowModule(), this);
return view;
}

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    //设置图片
    banner.loadImage(new XBanner.XBannerAdapter() {
        @Override
        public void loadBanner(XBanner banner, Object model, View view, int position) {
            MyResult result = (MyResult) model;
            Glide.with(getActivity()).load(result.getImageUrl()).into((ImageView) view);
        }
    });
    //创建布局管理器
    LinearLayoutManager manager = new LinearLayoutManager(getActivity());
    manager.setOrientation(LinearLayoutManager.VERTICAL);
    //设置布局管理器
    recyclerView.setLayoutManager(manager);
    //创建适配器
    adapter = new RecyclerAdapter(getActivity());
    //设置适配器
    recyclerView.setAdapter(adapter);
    //获取图片
    presenter.Showget(0, PicUrl);
    presenter.Showget(1, ShowUrl);
}

@Override
public void success(int type, String data) {
    if (type == 0) {
        Gson gson = new Gson();
        PicBean picBean = gson.fromJson(data, PicBean.class);
        List<MyResult> result = picBean.getResult();
        banner.setBannerData(result);
    } else if (type == 1) {
        Gson gson = new Gson();
        JavaBean javaBean = gson.fromJson(data, JavaBean.class);
        ResultBean result = javaBean.getResult();
        Rxxp rxxp = result.

今天的文章轮播图;list显示;Adapter分享到此就结束了,感谢您的阅读,如果确实帮到您,您可以动动手指转发给其他人。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/40084.html

(0)
编程小号编程小号

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注