回答編集履歴

2

Item を static 化

2023/01/16 16:29

投稿

jimbe
jimbe

スコア13209

test CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  MainActivity.Adapter に追加
5
5
  ```java
6
- private class Item {
6
+ private static class Item {
7
7
  final String name;
8
8
  boolean checked = false;
9
9
  Item(String name) {

1

onBindViewHolder の修正を追加

2023/01/16 08:41

投稿

jimbe
jimbe

スコア13209

test CHANGED
@@ -41,6 +41,13 @@
41
41
  StringJoiner sj = new StringJoiner(",");
42
42
  for(Item item : list) sj.add(item.name); //修正
43
43
  return sj.toString();
44
+ }
45
+
46
+ @Override
47
+ public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
48
+ Item item = list.get(position); //追加
49
+ holder.nameView.setText(item.name); //修正
50
+ holder.nameView.setChecked(item.checked); //追加
44
51
  }
45
52
  ```
46
53