我有一個RecyclerView,我要像下面如何從一個就是它的內部
總之形象創造的東西改變RecyclerView的元素:我想禁用選中的複選框被激活,當另一個列表被激活。
這是我RecyclerView適配器:
@Override
public void onBindViewHolder(final MyHolder holder, final int position) {
holder.checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
/*Here I want to disable this on. I need to have a single enabled checkbox.*/
//((CheckBox) holder.itemView.findViewById()).setChecked(false);
}
});
}
正如我可以禁用選中此上的複選框。 對不起,我的英語...
我看到你拒絕了我的編輯。沒關係,但我對你的回答仍有疑問。例如,這條if語句: 'if(currentCheckedPosition!= - 1)'永遠不會到達,因爲currentCheckedPosition正在改變裏面的值。而且,如果在更新currentCheckedPosition後不添加'notifyDatasetChanged()',則仍然可以在先前選擇的單元格上看到該檢查。我錯過了什麼嗎?祝一切順利。 –
你是對的朋友,對不起! –
好的。我重新發布我的編輯,如果你不介意 –