Without the interface, everything worked. I redo the OnItemClickListener through the interface, and everything works until the order of items gets lost when sorting, for example, when searching for 20, the position becomes the first and is processed as the first one. in this case?

here is the interface:

public interface OnItemClickListener { void onItemClick(View view, int position); } 

here is the adapter:

  @Override public void onClick(View v) { clickListener.onItemClick(v,getAdapterPosition()); } } void SetOnItemClickListener(final OnItemClickListener itemClickListener) { this.clickListener = itemClickListener; } вот сам фрагмент: public class Fragment_1extends Fragment implements SearchView.OnQueryTextListener,OnItemClickListener adapter.SetOnItemClickListener(this); @Override public void onItemClick(View view, int position) { Context context = view.getContext(); Intent i; i = new Intent(context, Detai.class); i.putExtra("pos2", StationList.get(position).getDetails_new()); context.startActivity(i); } 

and here's a class

 public class ItemBusStation implements Serializable { private String details1; public ItemBusStation( String details1) { this.details1 = details1; } public String getDetails1() { return details1; } 
  • one
    For data, you need to use a unique identifier, not a position in the list. If it is a database, then take it directly from the database, if you need to add another type of permanent storage yourself. - pavlofff
  • Maybe there is an example or where to read about it in order to do the right thing. The data is stored in the json file on the device - Romanych
  • And the second question is why does not get lost when searching for a position if I do not click through the interface - Romanych

0