2

I have looked at the previous answers to this problem and have added the @NonNull to the code but I am still getting the error. What could be causing the error?

@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);
    }
Vijer
  • 123
  • 4
  • 9
  • It is only a duplicate because the answers in the link were either not clear or incomplete. The answer provided by https://stackoverflow.com/users/5168011/guy completes the answer or makes it clearer. – Vijer Oct 27 '18 at 07:06

1 Answers1

4

The @NonNull should be over the method signature, and it should be in the override method as well

@Override
@NonNull
public NumberViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) { }
Guy
  • 46,488
  • 10
  • 44
  • 88