2017-08-07 14 views
0

活性のボタンのonclickこのコード:ボタンをクリックしてRecyclerViewのすべてのチェックボックスを選択する方法?

if(v.getId()==recomendationSelectAllFriends.getId()){ 
    recomendationAdapter.selectAll(resultEntities.size()); 
} 

この方法アダプタで:e.isCheckedフィールドはカードのチェックボックスに制限され

public void selectAll(int size){ 
    // what should be written here? 
} 
+0

https://stackoverflow.com/questions/4876083/correct-way-to-check-all-checkboxesで

if(resultEntities.get(position).isChecked(){ holder.yourCheckBoxName.setChecked(true); }else{ holder.yourCheckBoxName.setChecked(false); } 

を書きます-in-listviewこれをチェックする – AAA

答えて

0
public void selectAll(int size){ 
    // what should be written here? 

    for(DataEntity e: data) { //your list of data in the array 
     e.isChecked(true) 
    } 
    notifyDataSetChanged(); 
} 

0

モデルクラスにブール変数を追加し、その変数のゲッターとセッターをチェックして名前を付けます。

さて、では はあなたのonBindViewHolderあなたの機能

public void selectAll(){ 

    for(ResultEntity e: resultEntities) { 
     e.setChecked(true) 
    } 
    notifyDataSetChanged(); 
} 
関連する問題