is there a solution for accessing the first item in a recyclerView

108 Views Asked by At

I'm creating a user guide and one of my items that I want to describe in my user Guide is in my recycler View help me please I'm using this library : com.github.mreram:showcaseview:1.2.0

found the solution:

private var isPlayed = false
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
    holder.onFill(holder.adapterPosition)
    if (position == 0 && !isPlayed) {
        holder.guide()
        isPlayed = false
    }
}
1

There are 1 best solutions below

0
On BEST ANSWER

You can access recyclerview's first item by checking position of t he item in onBindview method

   public void onBindViewHolder(ViewHolder holder, int position) {

    if(position==0)
     // write your code here
    else
     // other code
   }