Find the view on the last position of RecyclerView?

后端 未结 3 855
广开言路
广开言路 2021-01-29 15:18

The below code is to find the view on the first position. How do I find the view on the last position?

TextView textView = 
  (TextView)myRecyclerView.findViewHo         


        
3条回答
  •  深忆病人
    2021-01-29 15:45

    try this

    TextView textView =(TextView)myRecyclerView.findViewHolderForAdapterPosition(mFirebaseAdapter.getItemCount()-1).itemView.findViewById(R.id.myTV); 
    

    try this

      TextView textView = (TextView) myRecyclerView.findViewHolderForAdapterPosition(arraylist.size()-1).itemView.findViewById(R.id.myTV);
    

    or try this

    simply you can do this:

    if(position == YouList.size()-1)
    {
      /*lastItem*/
    }
    

提交回复
热议问题