sử dụng logic, chúng tôi đã có với ListAdapter
. Điều này sẽ vô hiệu hóa các mục bộ điều hợp, thay vì cha mẹ của chúng.
public interface RecyclerViewItemEnabler{
public boolean isAllItemsEnabled();
public boolean getItemEnabled(int position);
}
Và thực hiện, nếu giống như thế này:
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());
}
}
Cách sử dụng: mRecylerAdapter.setAllItemsEnabled(!mSwipeRefreshLayout.isRefreshing());
Nguồn
2015-01-16 04:18:08
trình tốt! Cảm ơn bạn rất nhiều @NikolaDespotoski! – falvojr
Vì lý do nào đó, nó không hoạt động đối với tôi. Không chỉ tôi có thể nhấp vào tất cả các mục nhưng tất cả các mục cũng nhấp nháy đồng thời trên nhấp chuột. Tôi đã triển khai mã chính xác này, có vẻ thẳng về phía trước nhưng ... – iBobb