Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No ItemViewDelegate added that matches position=3 in data source #131

Open
minitriangle opened this issue Dec 11, 2019 · 2 comments
Open

Comments

@minitriangle
Copy link

minitriangle commented Dec 11, 2019

fixt this Exception you need to custom MultiItemTypeAdapter

fixit code

`
@OverRide
public int getItemViewType(int position) {
try {
return super.getItemViewType(position);
}catch (Exception e){
return -1;
}
}
@OverRide
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
if (viewType==-1){
Log.e("---",viewType+"**");
ItemViewDelegate itemViewDelegate = new EmptyDelegate();
int layoutId = itemViewDelegate.getItemViewLayoutId();
ViewHolder holder = ViewHolder.createViewHolder(mContext, parent, layoutId);
onViewHolderCreated(holder,holder.getConvertView());
setListener(parent, holder, viewType);
return holder;

    }
    return super.onCreateViewHolder(parent, viewType);
}

@Override
public void convert(ViewHolder holder, Object o) {
    try {
        super.convert(holder, o);
    }catch (Exception e){

    }
}

`

@minitriangle
Copy link
Author

EmptyDelegate() is height and width is 0dp layout

@yilylong
Copy link

yilylong commented Jan 2, 2020

正想提出这个问题,源码在找不到itemtype的情况直接抛出错误 似乎太粗暴 是不是在这种情况提供一个设置自定义空的itemtype的方法来兜底比较好。或者就只能像楼上的兄弟一样自定义处理

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants