在RecyclerView的最后位置找到视图? [英] Find the view on the last position of RecyclerView?

查看:115
本文介绍了在RecyclerView的最后位置找到视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码是在第一个位置找到视图。如何在最后位置找到视图?

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.findViewHolderForAdapterPosition(0).itemView.findViewById(R.id.myTV); //this is first position

这里是我的xml

    <android.support.v7.widget.RecyclerView
        android:id="@+id/messageRecyclerView"
       android:layout_width="match_parent"
       android:layout_height="match_parent"
        android:nestedScrollingEnabled="false" />


推荐答案

试试这个

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

试试这个

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

或试试这个

只需你可以这样做:

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

这篇关于在RecyclerView的最后位置找到视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆