Skip to content

设置数据源怎么设置View作为数据源,想实现不同的页面 #119

Open
@xiaolunan

Description

@xiaolunan

`private void initView() {
mList = new ArrayList<>();
inflater = LayoutInflater.from(this);
View view1 = inflater.inflate(R.layout.layout_1, null);
View view2 = inflater.inflate(R.layout.layout_1, null);
View view3 = inflater.inflate(R.layout.layout_1, null);
View view4 = inflater.inflate(R.layout.layout_1, null);
mList.add(view1);
mList.add(view2);
mList.add(view3);
mList.add(view4);
mzBannerView = findViewById(R.id.banner);
//设置是否显示Indicator
mzBannerView.setIndicatorVisible(false);
// 设置数据
mzBannerView.setPages(mList, new MZHolderCreator() {
@OverRide
public BannerViewHolder createViewHolder() {
return new BannerViewHolder();
}
});
}

public static class BannerViewHolder implements MZViewHolder<View> {

    @Override
    public View createView(Context context) {
        // 返回页面布局
        View view = LayoutInflater.from(context).inflate(R.layout.banner_item, null);
        return view;
    }

    @Override
    public void onBind(Context context, int position, View data) {

    }
}`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions