2016-05-24 39 views

回答

1

終於我找到了! 根視圖持有者項目的佈局參數是GridLayoutManager.LayoutParams並且具有getSpanIndex()方法。

RecyclerView.ViewHolder viewHolder = m_RecyclerView.findViewHolderForAdapterPosition(position); 
if (viewHolder != null) { 
    GridLayoutManager.LayoutParams lp = (GridLayoutManager.LayoutParams) viewHolder.itemView.getLayoutParams(); 
    int spanIndex = lp.getSpanIndex(); 
}