Find the view on the last position of RecyclerView?

后端 未结 3 853
广开言路
广开言路 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*/
    }
    
    0 讨论(0)
  • 2021-01-29 15:59
    TextView textView =(TextView)myRecyclerView.findViewHolderForAdapterPosition(Arraylist.size()-1).itemView.findViewById(R.id.myTV); 
    
    0 讨论(0)
  • 2021-01-29 16:02

    You can try this

    TextView textView = (TextView) myRecyclerView.findViewHolderForAdapterPosition(myRecyclerView.getAdapter().getItemCount() - 1).itemView.findViewById(R.id.myTV);
    
    0 讨论(0)
提交回复
热议问题