There is a RecyclerView with 2 ViewHolders, where the JSON object comes in, which has a list, which I actually display. But according to my idea, I should get two types of elements, instead of three. The first is TYPE_TEXTVIEW; The second is TYPE_EDITVIEW; and the third is all the rest. The third item in my list (pictured below) is displayed as "Not found".

enter image description here

We advised to remove (sort) this element from my list itself by creating a loop:

public void onResponse(Call<DropDown> call, Response<DropDown> response) { DropDown jsonResponse = response.body(); for(Groupss g :jsonResponse.getForm().getmGroupss()) { if (g.getmControls() != null && g.getmControls().size() > 0 && "type".equals(g.getmControls().get(0).getTitle())) { mList.add(g); } } 

Please tell me how to remove an unnecessary element in the method?

  • It seems to me that one of the elements matches your condition for NOT_FOUND - if (mList.get(position).getmControls().size()>0) is not satisfied for it, or mList.get(position).getmControls().get(0).getTitle() does not match the strings from case - Vladyslav Matviienko
  • @metalurgus Suppose you are right, how can a problem be solved? - Morozov
  • Add, for example, some log in getItemViewType() , and see if I guessed correctly. - Vladyslav Matviienko
  • @metalurgus Where default: temp = 1; Additionally set default: Log.d ("check", String.valueOf (temp = 1)); ? I'm getting lost a bit ... - Morozov
  • before return temp; write Log.d("check","return " + temp + "; position = " + position); - Vladyslav Matviienko

0