Where on the list with recyclerview

Asked

Viewed 24 times

0

I need to get the position of an item in the list, where the code is what I passed. In C# I do this like Python, 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

1 answer

0

Inside your Adapter you can make a way like this

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.