質問編集履歴

2

エラーの原因がXML上にあるのではないかという指摘より.xmlを提示した

2018/08/21 11:00

投稿

hama1185
hama1185

スコア18

test CHANGED
File without changes
test CHANGED
@@ -32,163 +32,79 @@
32
32
 
33
33
  ボタンについて書いてる文だけいれます
34
34
 
35
- ```kotlin
35
+ ```activity_main.xml
36
36
 
37
+ <?xml version="1.0" encoding="utf-8"?>
38
+
39
+ <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
40
+
41
+ xmlns:app="http://schemas.android.com/apk/res-auto"
42
+
43
+ xmlns:tools="http://schemas.android.com/tools"
44
+
45
+ android:layout_width="match_parent"
46
+
47
+ android:layout_height="match_parent"
48
+
37
- class MainActivity : AppCompatActivity(), DataStoreEventListener {
49
+ tools:context=".MainActivity">
38
50
 
39
51
 
40
52
 
53
+ <LinearLayout
41
54
 
55
+ android:layout_width="0dp"
42
56
 
43
- val app_id : String = "dogjkn9fo6y.mlkcca.com"
57
+ android:layout_height="0dp"
44
58
 
45
- val key : String = "esp32"
59
+ android:orientation="vertical"
60
+
61
+ app:layout_constraintBottom_toBottomOf="parent"
62
+
63
+ app:layout_constraintEnd_toEndOf="parent"
64
+
65
+ app:layout_constraintStart_toStartOf="parent"
66
+
67
+ app:layout_constraintTop_toTopOf="parent">
46
68
 
47
69
 
48
70
 
49
- var player_name : String = "player"
71
+ <Button
50
72
 
51
- val handler : Handler = Handler()
73
+ android:id="@+id/button1"
52
74
 
53
- var timer : Timer? = null
75
+ android:layout_width="match_parent"
76
+
77
+ android:layout_height="wrap_content"
78
+
79
+ android:text="Player1" />
54
80
 
55
81
 
56
82
 
57
- var penaltyButton : PenaltyButton? = null
83
+ <Button
58
84
 
59
- var milkcocoa : MilkCocoa? = null
85
+ android:id="@+id/button2"
60
86
 
61
- var dataStore : DataStore? = null
87
+ android:layout_width="match_parent"
88
+
89
+ android:layout_height="wrap_content"
90
+
91
+ android:text="Player2" />
62
92
 
63
93
 
64
94
 
65
- val time_pattern : LongArray = longArrayOf(3000, 3000, 3000, 3000, 3000, 3000, 3000, 3000, 3000, 3000)
95
+ <Button
66
96
 
67
- var decideVib : DecideVib? = null
97
+ android:id="@+id/penalty_button"
68
98
 
99
+ android:layout_width="match_parent"
69
100
 
101
+ android:layout_height="373dp"
70
102
 
71
- var decideWin : DecideWin? = null
103
+ android:text="Touch!!!!!" />
72
104
 
105
+ </LinearLayout>
73
106
 
74
-
75
- var p1_current : String? = null
76
-
77
- var p2_current : String? = null
78
-
79
- var decision : Int? = null
80
-
81
-
82
-
83
- var flag : IntArray = intArrayOf(0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
84
-
85
- var i : Int = 0
86
-
87
-
88
-
89
- override fun onCreate(savedInstanceState: Bundle?) {
90
-
91
- super.onCreate(savedInstanceState)
92
-
93
- setContentView(R.layout.activity_main)
94
-
95
-
96
-
97
- milkcocoa = MilkCocoa(app_id)
98
-
99
- dataStore = milkcocoa?.dataStore(key)
100
-
101
- //var s_listener : DataStoreEventListener = dataStore.
107
+ </android.support.constraint.ConstraintLayout>
102
-
103
- dataStore?.addDataStoreEventListener(this)
104
-
105
- dataStore?.on("send")
106
-
107
-
108
-
109
-
110
-
111
- val button1 : Button = findViewById<Button>(R.id.button1)
112
-
113
- val button2 : Button = findViewById<Button>(R.id.button2)
114
-
115
-
116
-
117
- val p_button : Button = findViewById<Button>(R.id.penalty_button)
118
-
119
-
120
-
121
- val listener = View.OnClickListener {
122
-
123
- v: View? ->
124
-
125
- when (v?.id) {
126
-
127
- button1.id -> {
128
-
129
- player_name = "player1"
130
-
131
-
132
-
133
- button1.visibility = View.GONE
134
-
135
- button2.visibility = View.GONE
136
-
137
-
138
-
139
- }
140
-
141
- button2.id -> {
142
-
143
- player_name = "player2"
144
-
145
-
146
-
147
- button1.visibility = View.GONE
148
-
149
- button2.visibility = View.GONE
150
-
151
-
152
-
153
- }
154
-
155
-
156
-
157
- p_button.id -> {
158
-
159
- penaltyButton = PenaltyButton(this, handler, p_button)
160
-
161
- timer = Timer(true)
162
-
163
- p_button.visibility = View.INVISIBLE
164
-
165
- timer?.schedule(penaltyButton, 15000)
166
-
167
-
168
-
169
- decideWin = DecideWin(this, handler, decision, player_name)
170
-
171
- decideWin
172
-
173
- }
174
-
175
- }
176
-
177
- }
178
-
179
-
180
-
181
- button1.setOnClickListener(listener)
182
-
183
- button2.setOnClickListener(listener)
184
-
185
- p_button.setOnClickListener(listener)
186
-
187
-
188
-
189
-
190
-
191
- }
192
108
 
193
109
  ```
194
110
 

1

エラー文の追加

2018/08/21 11:00

投稿

hama1185
hama1185

スコア18

test CHANGED
File without changes
test CHANGED
@@ -6,7 +6,11 @@
6
6
 
7
7
  ### 発生している問題・エラーメッセージ
8
8
 
9
- 特にエラー発生しなかった
9
+ ソース上ではエラー発生しなかったのだが
10
+
11
+ activity_main.xml上でのエラーが発生した
12
+
13
+ > Failed to load AppCompat ActionBar with unknown error.
10
14
 
11
15
  表示されるはずの3つのボタンが表示されなかった
12
16