Where in the list with recyclerview

0

I need to get the position of an item in the list where the code is what I went through. In C # I do this as linq, how to do in java?

    public void onBindViewHolder(final LineHolder_Entidade holder, final int position) {
    Context holder_Context = holder.itemView.getContext();

    int oPosicao =  oEntidades.get(position).getCodigo();// onde o código == 2
    
asked by anonymous 08.05.2018 / 15:45

1 answer

0

Within your adapter you can do a method like this

public int findBy(Int cod){
  foreach(Entidade e: oEntidades){
    if(e.getCodigo().equals(cod))
    return oEntidades.indexOf(e);
  }
  return -1;
}
    
08.05.2018 / 18:57