回答編集履歴
4
誤字
test
CHANGED
@@ -19,7 +19,7 @@
|
|
19
19
|
---
|
20
20
|
ちゃんと(?)やるならば、行のデータをクラス化して 1 つのリストとして扱うことです。
|
21
21
|
|
22
|
-
```ko
|
22
|
+
```kotlin
|
23
23
|
data class Row(val name: String, val info: String)
|
24
24
|
```
|
25
25
|
```kotlin
|
3
追加
test
CHANGED
@@ -15,3 +15,29 @@
|
|
15
15
|
holder.characterList.text = list[position]
|
16
16
|
holder.characterList2.text = list2[position]
|
17
17
|
```
|
18
|
+
|
19
|
+
---
|
20
|
+
ちゃんと(?)やるならば、行のデータをクラス化して 1 つのリストとして扱うことです。
|
21
|
+
|
22
|
+
```korlin
|
23
|
+
data class Row(val name: String, val info: String)
|
24
|
+
```
|
25
|
+
```kotlin
|
26
|
+
val rowList = listOf(
|
27
|
+
Row("ボブ","アイスクリームが好き"),
|
28
|
+
Row("エミリー","ハチミツが好き"),
|
29
|
+
Row("マイク","運動が好き"),
|
30
|
+
Row("サム","アウトドアが好き"),
|
31
|
+
Row("エドワード","野球観戦が好き")
|
32
|
+
)
|
33
|
+
```
|
34
|
+
```kotlin
|
35
|
+
recyclerView.adapter = RecyclerAdapter(rowList)
|
36
|
+
```
|
37
|
+
```kotlin
|
38
|
+
class RecyclerAdapter(val list: List<Row>) : RecyclerView.Adapter<ViewHolderList>() {
|
39
|
+
```
|
40
|
+
```kotlin
|
41
|
+
holder.characterList.text = list[position].name
|
42
|
+
holder.characterList2.text = list[position].info
|
43
|
+
```
|
2
追加
test
CHANGED
@@ -1,3 +1,17 @@
|
|
1
1
|
~~[【Kotlin】ListViewの使い方 ②テキストを2つ表示する](https://codeforfun.jp/kotlin-listview-with-two-textview/)~~
|
2
2
|
|
3
3
|
[[Kotlin de Android] RecyclerViewで2行表示するリスト表示してみよう](https://www.usaco-pg.com/2020/12/30/kotlin-de-android-recyclerview2/)
|
4
|
+
|
5
|
+
---
|
6
|
+
簡単に修正するのでしたらアダプタにリストを 2 つ持たせてしまうことでしょう。
|
7
|
+
|
8
|
+
```kotlin
|
9
|
+
recyclerView.adapter = RecyclerAdapter(TextList, TextList2)
|
10
|
+
```
|
11
|
+
```kotlin
|
12
|
+
class RecyclerAdapter(val list: List<String>, val list2: List<String>) : RecyclerView.Adapter<ViewHolderList>() {
|
13
|
+
```
|
14
|
+
```kotlin
|
15
|
+
holder.characterList.text = list[position]
|
16
|
+
holder.characterList2.text = list2[position]
|
17
|
+
```
|
1
修正
test
CHANGED
@@ -1,2 +1,3 @@
|
|
1
|
-
[【Kotlin】ListViewの使い方 ②テキストを2つ表示する](https://codeforfun.jp/kotlin-listview-with-two-textview/)
|
1
|
+
~~[【Kotlin】ListViewの使い方 ②テキストを2つ表示する](https://codeforfun.jp/kotlin-listview-with-two-textview/)~~
|
2
2
|
|
3
|
+
[[Kotlin de Android] RecyclerViewで2行表示するリスト表示してみよう](https://www.usaco-pg.com/2020/12/30/kotlin-de-android-recyclerview2/)
|