使用我们处理过的逻辑
ListAdapter。这将禁用适配器项,而不是其父项。
public interface RecyclerViewItemEnabler{ public boolean isAllItemsEnabled(); public boolean getItemEnabled(int position);}
实现应如下所示:
public class RecyclerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements RecyclerViewItemEnabler{ @Override public void onViewAttachedToWindow(RecyclerView.ViewHolder holder) { super.onViewAttachedToWindow(holder); holder.itemView.setEnabled(isAllItemsEnabled()); //or do this in onBindViewHolder() } @Override public boolean isAllItemsEnabled(){ return mAllEnabled; } @Override public boolean getItemEnabled(int position){ return true; } public void setAllItemsEnabled(boolean enable){ mAllEnabled = enable; notifyItemRangeChanged(0, getItemCount()); }}
用法:
mRecylerAdapter.setAllItemsEnabled(!mSwipeRefreshLayout.isRefreshing());
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)