Skip to content

How to get Position? #12

@erfannf

Description

@erfannf

For animating items in ViewBinder method, I need to check if RecyclerView is scrolling up or down. In custom adapters, I usually add a global variable LASTPOSITION and compare it to current position for detecting up or down scroll for proper animation. How can we do so in RendererRecyclerViewAdapter? Also, how can access adapterPosition or position in ViewBinder?

FYI:

  @Override
    public void onBindViewHolder(final RecyclerView.ViewHolder viewHolder, int position) {
           Animation animation = AnimationUtils.loadAnimation(mActivity, (position > lastPosition) ? R.anim.up_from_bottom : R.anim.down_from_top);
         viewHolder.itemView.startAnimation(animation);
         lastPosition = position;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions