質問編集履歴
6
こーど
test
CHANGED
File without changes
|
test
CHANGED
@@ -569,3 +569,13 @@
|
|
569
569
|
|
570
570
|
|
571
571
|
```
|
572
|
+
|
573
|
+
```C#
|
574
|
+
|
575
|
+
Button btnM = FindViewById<Button>(Resource.Id.btnSayHello);
|
576
|
+
|
577
|
+
TextView txtV = FindViewById<TextView>(Resource.Id.txtMsg);
|
578
|
+
|
579
|
+
```
|
580
|
+
|
581
|
+
にたいして ResouceにIDの定義がありませんと出てきます
|
5
こーど
test
CHANGED
File without changes
|
test
CHANGED
@@ -295,3 +295,277 @@
|
|
295
295
|
```
|
296
296
|
|
297
297
|
これらのコードに対して現在のコンテキストにresourceという名前は存在しません
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
追記4再度作り直しました
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
MainActivity.cs
|
306
|
+
|
307
|
+
```
|
308
|
+
|
309
|
+
using Android.App;
|
310
|
+
|
311
|
+
using Android.Widget;
|
312
|
+
|
313
|
+
using Android.OS;
|
314
|
+
|
315
|
+
|
316
|
+
|
317
|
+
namespace App5
|
318
|
+
|
319
|
+
{
|
320
|
+
|
321
|
+
[Activity(Label = "DroidSample", MainLauncher = true, Icon = "@drawable/icon")]
|
322
|
+
|
323
|
+
public class MainActivity : Activity
|
324
|
+
|
325
|
+
{
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
protected override void OnCreate(Bundle bundle)
|
330
|
+
|
331
|
+
{
|
332
|
+
|
333
|
+
base.OnCreate(bundle);
|
334
|
+
|
335
|
+
|
336
|
+
|
337
|
+
// Set our view from the "main" layout resource
|
338
|
+
|
339
|
+
SetContentView(Resource.Layout.Main);
|
340
|
+
|
341
|
+
|
342
|
+
|
343
|
+
Button btnM = FindViewById<Button>(Resource.Id.btnSayHello);
|
344
|
+
|
345
|
+
TextView txtV = FindViewById<TextView>(Resource.Id.txtMsg);
|
346
|
+
|
347
|
+
|
348
|
+
|
349
|
+
btnM.Click += delegate
|
350
|
+
|
351
|
+
{
|
352
|
+
|
353
|
+
txtV.Text = "こんにちは";
|
354
|
+
|
355
|
+
};
|
356
|
+
|
357
|
+
}
|
358
|
+
|
359
|
+
}
|
360
|
+
|
361
|
+
}
|
362
|
+
|
363
|
+
|
364
|
+
|
365
|
+
```
|
366
|
+
|
367
|
+
Main.axml
|
368
|
+
|
369
|
+
```C#
|
370
|
+
|
371
|
+
<?xml version="1.0" encoding="utf-8"?>
|
372
|
+
|
373
|
+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
374
|
+
|
375
|
+
android:orientation="vertical"
|
376
|
+
|
377
|
+
android:layout_width="match_parent"
|
378
|
+
|
379
|
+
android:layout_height="match_parent">
|
380
|
+
|
381
|
+
<Button
|
382
|
+
|
383
|
+
android:text="Button"
|
384
|
+
|
385
|
+
android:layout_width="match_parent"
|
386
|
+
|
387
|
+
android:layout_height="wrap_content"
|
388
|
+
|
389
|
+
android:id="@+id/btnSayHello" />
|
390
|
+
|
391
|
+
<TextView
|
392
|
+
|
393
|
+
android:text="Large Text"
|
394
|
+
|
395
|
+
android:textAppearance="?android:attr/textAppearanceLarge"
|
396
|
+
|
397
|
+
android:layout_width="match_parent"
|
398
|
+
|
399
|
+
android:layout_height="wrap_content"
|
400
|
+
|
401
|
+
android:id="@+id/txtMsg" />
|
402
|
+
|
403
|
+
</LinearLayout>
|
404
|
+
|
405
|
+
```
|
406
|
+
|
407
|
+
Resource.Designer.cs
|
408
|
+
|
409
|
+
|
410
|
+
|
411
|
+
も追記しておきました
|
412
|
+
|
413
|
+
```C#
|
414
|
+
|
415
|
+
#pragma warning disable 1591
|
416
|
+
|
417
|
+
//------------------------------------------------------------------------------
|
418
|
+
|
419
|
+
// <auto-generated>
|
420
|
+
|
421
|
+
// このコードはツールによって生成されました。
|
422
|
+
|
423
|
+
// ランタイム バージョン:4.0.30319.42000
|
424
|
+
|
425
|
+
//
|
426
|
+
|
427
|
+
// このファイルへの変更は、以下の状況下で不正な動作の原因になったり、
|
428
|
+
|
429
|
+
// コードが再生成されるときに損失したりします。
|
430
|
+
|
431
|
+
// </auto-generated>
|
432
|
+
|
433
|
+
//------------------------------------------------------------------------------
|
434
|
+
|
435
|
+
|
436
|
+
|
437
|
+
[assembly: global::Android.Runtime.ResourceDesignerAttribute("App5.Resource", IsApplication=true)]
|
438
|
+
|
439
|
+
|
440
|
+
|
441
|
+
namespace App5
|
442
|
+
|
443
|
+
{
|
444
|
+
|
445
|
+
|
446
|
+
|
447
|
+
|
448
|
+
|
449
|
+
[System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "1.0.0.0")]
|
450
|
+
|
451
|
+
public partial class Resource
|
452
|
+
|
453
|
+
{
|
454
|
+
|
455
|
+
|
456
|
+
|
457
|
+
static Resource()
|
458
|
+
|
459
|
+
{
|
460
|
+
|
461
|
+
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
|
462
|
+
|
463
|
+
}
|
464
|
+
|
465
|
+
|
466
|
+
|
467
|
+
public static void UpdateIdValues()
|
468
|
+
|
469
|
+
{
|
470
|
+
|
471
|
+
}
|
472
|
+
|
473
|
+
|
474
|
+
|
475
|
+
public partial class Attribute
|
476
|
+
|
477
|
+
{
|
478
|
+
|
479
|
+
|
480
|
+
|
481
|
+
static Attribute()
|
482
|
+
|
483
|
+
{
|
484
|
+
|
485
|
+
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
|
486
|
+
|
487
|
+
}
|
488
|
+
|
489
|
+
|
490
|
+
|
491
|
+
private Attribute()
|
492
|
+
|
493
|
+
{
|
494
|
+
|
495
|
+
}
|
496
|
+
|
497
|
+
}
|
498
|
+
|
499
|
+
|
500
|
+
|
501
|
+
public partial class Layout
|
502
|
+
|
503
|
+
{
|
504
|
+
|
505
|
+
|
506
|
+
|
507
|
+
// aapt resource value: 0x7f020000
|
508
|
+
|
509
|
+
public const int Main = 2130837504;
|
510
|
+
|
511
|
+
|
512
|
+
|
513
|
+
static Layout()
|
514
|
+
|
515
|
+
{
|
516
|
+
|
517
|
+
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
|
518
|
+
|
519
|
+
}
|
520
|
+
|
521
|
+
|
522
|
+
|
523
|
+
private Layout()
|
524
|
+
|
525
|
+
{
|
526
|
+
|
527
|
+
}
|
528
|
+
|
529
|
+
}
|
530
|
+
|
531
|
+
|
532
|
+
|
533
|
+
public partial class String
|
534
|
+
|
535
|
+
{
|
536
|
+
|
537
|
+
|
538
|
+
|
539
|
+
// aapt resource value: 0x7f030000
|
540
|
+
|
541
|
+
public const int app_name = 2130903040;
|
542
|
+
|
543
|
+
|
544
|
+
|
545
|
+
static String()
|
546
|
+
|
547
|
+
{
|
548
|
+
|
549
|
+
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
|
550
|
+
|
551
|
+
}
|
552
|
+
|
553
|
+
|
554
|
+
|
555
|
+
private String()
|
556
|
+
|
557
|
+
{
|
558
|
+
|
559
|
+
}
|
560
|
+
|
561
|
+
}
|
562
|
+
|
563
|
+
}
|
564
|
+
|
565
|
+
}
|
566
|
+
|
567
|
+
#pragma warning restore 1591
|
568
|
+
|
569
|
+
|
570
|
+
|
571
|
+
```
|
4
コード付け足し
test
CHANGED
File without changes
|
test
CHANGED
@@ -165,3 +165,133 @@
|
|
165
165
|
</LinearLayout>
|
166
166
|
|
167
167
|
```
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
追記3
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
上のプログラムがなぜか起動できなくなったので再度作り直しました。
|
176
|
+
|
177
|
+
コードは以下に示します。
|
178
|
+
|
179
|
+
Main.axml
|
180
|
+
|
181
|
+
```C#
|
182
|
+
|
183
|
+
<?xml version="1.0" encoding="utf-8"?>
|
184
|
+
|
185
|
+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
186
|
+
|
187
|
+
android:orientation="vertical"
|
188
|
+
|
189
|
+
android:layout_width="match_parent"
|
190
|
+
|
191
|
+
android:layout_height="match_parent">
|
192
|
+
|
193
|
+
<Button
|
194
|
+
|
195
|
+
android:text="Button"
|
196
|
+
|
197
|
+
android:layout_width="match_parent"
|
198
|
+
|
199
|
+
android:layout_height="wrap_content"
|
200
|
+
|
201
|
+
android:id="@+id/btnSayHello" />
|
202
|
+
|
203
|
+
<TextView
|
204
|
+
|
205
|
+
android:text="Large Text"
|
206
|
+
|
207
|
+
android:textAppearance="?android:attr/textAppearanceLarge"
|
208
|
+
|
209
|
+
android:layout_width="match_parent"
|
210
|
+
|
211
|
+
android:layout_height="wrap_content"
|
212
|
+
|
213
|
+
android:id="@+id/txtMsg" />
|
214
|
+
|
215
|
+
</LinearLayout>
|
216
|
+
|
217
|
+
```
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
MainActivity.cs
|
222
|
+
|
223
|
+
```C#
|
224
|
+
|
225
|
+
using Android.App;
|
226
|
+
|
227
|
+
using Android.Widget;
|
228
|
+
|
229
|
+
using Android.OS;
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
namespace anti_offtime
|
234
|
+
|
235
|
+
{
|
236
|
+
|
237
|
+
[Activity(Label = "offtimekiller", MainLauncher = true, Icon = "@drawable/icon")]
|
238
|
+
|
239
|
+
public class MainActivity : Activity
|
240
|
+
|
241
|
+
{
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
protected override void OnCreate(Bundle bundle)
|
246
|
+
|
247
|
+
{
|
248
|
+
|
249
|
+
base.OnCreate(bundle);
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
// Set our view from the "main" layout resource
|
254
|
+
|
255
|
+
SetContentView(Resource.Layout.Main);
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
Button btnM = FindViewById<Button>(Resource.Id.btnSayHello);
|
260
|
+
|
261
|
+
TextView txtV = FindViewById<TextView>(Resource.Id.txtMsg);
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
btnM.Click += delegate
|
266
|
+
|
267
|
+
{
|
268
|
+
|
269
|
+
txtV.Text = "こんにちは";
|
270
|
+
|
271
|
+
};
|
272
|
+
|
273
|
+
}
|
274
|
+
|
275
|
+
}
|
276
|
+
|
277
|
+
}
|
278
|
+
|
279
|
+
```
|
280
|
+
|
281
|
+
エラーが
|
282
|
+
|
283
|
+
```C#
|
284
|
+
|
285
|
+
// Set our view from the "main" layout resource
|
286
|
+
|
287
|
+
SetContentView(Resource.Layout.Main);
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
Button btnM = FindViewById<Button>(Resource.Id.btnSayHello);
|
292
|
+
|
293
|
+
TextView txtV = FindViewById<TextView>(Resource.Id.txtMsg);
|
294
|
+
|
295
|
+
```
|
296
|
+
|
297
|
+
これらのコードに対して現在のコンテキストにresourceという名前は存在しません
|
3
code 追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -116,6 +116,8 @@
|
|
116
116
|
|
117
117
|
追記2
|
118
118
|
|
119
|
+
Main.axml
|
120
|
+
|
119
121
|
```C#
|
120
122
|
|
121
123
|
<?xml version="1.0" encoding="utf-8"?>
|
2
コード追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -113,3 +113,53 @@
|
|
113
113
|
}
|
114
114
|
|
115
115
|
```
|
116
|
+
|
117
|
+
追記2
|
118
|
+
|
119
|
+
```C#
|
120
|
+
|
121
|
+
<?xml version="1.0" encoding="utf-8"?>
|
122
|
+
|
123
|
+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
124
|
+
|
125
|
+
android:orientation="vertical"
|
126
|
+
|
127
|
+
android:layout_width="match_parent"
|
128
|
+
|
129
|
+
android:layout_height="match_parent">
|
130
|
+
|
131
|
+
<Button
|
132
|
+
|
133
|
+
android:text="btnSayHello"
|
134
|
+
|
135
|
+
android:layout_width="match_parent"
|
136
|
+
|
137
|
+
android:layout_height="wrap_content"
|
138
|
+
|
139
|
+
android:id="@+id/btnSayHello" />
|
140
|
+
|
141
|
+
<TextView
|
142
|
+
|
143
|
+
android:textAppearance="?android:attr/textAppearanceLarge"
|
144
|
+
|
145
|
+
android:layout_width="match_parent"
|
146
|
+
|
147
|
+
android:layout_height="wrap_content"
|
148
|
+
|
149
|
+
android:id="@+txtMsg" />
|
150
|
+
|
151
|
+
<TextView
|
152
|
+
|
153
|
+
android:text="Large Text"
|
154
|
+
|
155
|
+
android:textAppearance="?android:attr/textAppearanceLarge"
|
156
|
+
|
157
|
+
android:layout_width="match_parent"
|
158
|
+
|
159
|
+
android:layout_height="wrap_content"
|
160
|
+
|
161
|
+
android:id="@+id/textMsg" />
|
162
|
+
|
163
|
+
</LinearLayout>
|
164
|
+
|
165
|
+
```
|
1
コードの追加(返信ではできないため)
test
CHANGED
File without changes
|
test
CHANGED
@@ -35,3 +35,81 @@
|
|
35
35
|
何を書けばいいのかさっぱりわかりません。
|
36
36
|
|
37
37
|
どうすればエラーが解けるか回答お願いします。
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
追記1
|
56
|
+
|
57
|
+
MainActivity.csのコードです。
|
58
|
+
|
59
|
+
```C#
|
60
|
+
|
61
|
+
using Android.App;
|
62
|
+
|
63
|
+
using Android.Widget;
|
64
|
+
|
65
|
+
using Android.OS;
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
namespace anti_offtime
|
70
|
+
|
71
|
+
{
|
72
|
+
|
73
|
+
[Activity(Label = "DroidSample", MainLauncher = true, Icon = "@drawable/icon")]
|
74
|
+
|
75
|
+
public class MainActivity : Activity
|
76
|
+
|
77
|
+
{
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
protected override void OnCreate(Bundle bundle)
|
82
|
+
|
83
|
+
{
|
84
|
+
|
85
|
+
base.OnCreate(bundle);
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
// Set our view from the "main" layout resource
|
90
|
+
|
91
|
+
SetContentView(Resource.Layout.Main);
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
Button btnM = FindViewById<Button>(Resource.Id.btnSayHello);
|
96
|
+
|
97
|
+
TextView txtV = FindViewById<TextView>(Resource.Id.txtMsg);
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
btnM.Click += delegate
|
102
|
+
|
103
|
+
{
|
104
|
+
|
105
|
+
txtV.Text = "こんにちは";
|
106
|
+
|
107
|
+
};
|
108
|
+
|
109
|
+
}
|
110
|
+
|
111
|
+
}
|
112
|
+
|
113
|
+
}
|
114
|
+
|
115
|
+
```
|