質問編集履歴
1
onCreate以下を省略せずに書きました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -46,9 +46,65 @@
|
|
46
46
|
|
47
47
|
|
48
48
|
|
49
|
+
loadBoard()
|
49
50
|
|
50
51
|
|
52
|
+
|
53
|
+
private fun loadBoard() {
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
for (i in boardCells.indices) {
|
58
|
+
|
59
|
+
for (j in boardCells.indices) {
|
60
|
+
|
61
|
+
boardCells[i][j] = Button(this)
|
62
|
+
|
63
|
+
boardCells[i][j]?.layoutParams = GridLayout.LayoutParams().apply {
|
64
|
+
|
65
|
+
rowSpec = GridLayout.spec(i)
|
66
|
+
|
67
|
+
columnSpec = GridLayout.spec(j)
|
68
|
+
|
69
|
+
width = 285 - (21*colRow)
|
70
|
+
|
71
|
+
height = 285 - (21*colRow)
|
72
|
+
|
73
|
+
bottomMargin = 5
|
74
|
+
|
75
|
+
topMargin = 5
|
76
|
+
|
77
|
+
leftMargin = 5
|
78
|
+
|
79
|
+
rightMargin = 5
|
80
|
+
|
81
|
+
}
|
82
|
+
|
83
|
+
layout_board.addView(boardCells[i][j])
|
84
|
+
|
85
|
+
boardCells[i][j]?.setOnClickListener(CellClickListener1(i, j))
|
86
|
+
|
87
|
+
boardCells[i][j]?.setBackgroundColor(
|
88
|
+
|
89
|
+
ContextCompat.getColor(
|
90
|
+
|
91
|
+
this,
|
92
|
+
|
93
|
+
R.color.colorPrimary
|
94
|
+
|
95
|
+
)
|
96
|
+
|
97
|
+
)
|
98
|
+
|
99
|
+
}
|
100
|
+
|
51
101
|
}
|
102
|
+
|
103
|
+
}
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
}
|
52
108
|
|
53
109
|
```
|
54
110
|
|
@@ -74,6 +130,8 @@
|
|
74
130
|
|
75
131
|
|
76
132
|
|
133
|
+
|
134
|
+
|
77
135
|
```
|
78
136
|
|
79
137
|
intent の値を onCreate 以外で受け取る方法あるいは、private val boardCells配列へonCreateから値を送る方法をご存じでしたら教えてください。よろしくお願いいたします。
|