Android examples for User Interface:RecyclerView
get RecyclerView Layout Position
import android.support.v7.widget.RecyclerView; import android.view.View; public class Main{ /*from w w w . j a v a 2 s .c o m*/ public static int getLayoutPosition(RecyclerView recyclerView, RecyclerView.ViewHolder holder) { RecyclerView.Adapter outerAdapter = recyclerView.getAdapter(); if (outerAdapter != null && outerAdapter instanceof MTFRecyclerViewAdapterWrapper) { int headerViewCounter = ((MTFRecyclerViewAdapterWrapper) outerAdapter) .getHeaderViewsCount(); if (headerViewCounter > 0) { return holder.getLayoutPosition() - headerViewCounter; } } return holder.getLayoutPosition(); } }