我已经看过以前对这个问题的回答,并已将@NonNull添加到代码中,但是仍然出现错误。可能是什么原因导致错误?
@Override
public NumberViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int viewType) {
Context context = viewGroup.getContext();
int layoutIdForListItem = R.layout.number_list_item;
LayoutInflater inflater = LayoutInflater.from(context);
View view = inflater.inflate(layoutIdForListItem, viewGroup, false);
return new NumberViewHolder(view);
}
答案 0 :(得分:2)
@NonNull
应该在方法签名上,并且也应该在重写方法中
@Override
@NonNull
public NumberViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) { }