1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
|
page.title=More Resource Types
parent.title=Resource Types
parent.link=available-resources.html
@jd:body
<p>This page defines more types of resources you can externalize, including:</p>
<dl>
<dt><a href="#Bool">Bool</a></dt>
<dd>XML resource that carries a boolean value.</dd>
<dt><a href="#Color">Color</a></dt>
<dd>XML resource that carries a color value (a hexadecimal color).</dd>
<dt><a href="#Dimension">Dimension</a></dt>
<dd>XML resource that carries a dimension value (with a unit of measure).</dd>
<dt><a href="#Id">ID</a></dt>
<dd>XML resource that provides a unique identifier for application resources and
components.</dd>
<dt><a href="#Integer">Integer</a></dt>
<dd>XML resource that carries an integer value.</dd>
<dt><a href="#IntegerArray">Integer Array</a></dt>
<dd>XML resource that provides an array of integers.</dd>
<dt><a href="#TypedArray">Typed Array</a></dt>
<dd>XML resource that provides a {@link android.content.res.TypedArray} (which you can use
for an array of drawables).</dd>
</dl>
<h2 id="Bool">Bool</h2>
<p>A boolean value defined in XML.</p>
<p class="note"><strong>Note:</strong> A bool is a simple resource that is referenced
using the value provided in the {@code name} attribute (not the name of the XML file). As
such, you can combine bool resources with other simple resources in the one XML file,
under one {@code <resources>} element.</p>
<dl class="xml">
<dt>file location:</dt>
<dd><code>res/values/<em>filename</em>.xml</code><br/>
The filename is arbitrary. The {@code <bool>} element's {@code name} will be used as the resource
ID.</dd>
<dt>resource reference:</dt>
<dd>
In Java: <code>R.bool.<em>bool_name</em></code><br/>
In XML: <code>@[<em>package</em>:]bool/<em>bool_name</em></code>
</dd>
<dt>syntax:</dt>
<dd>
<pre class="stx">
<?xml version="1.0" encoding="utf-8"?>
<<a href="#bool-resources-element">resources</a>>
<<a href="#bool-element">bool</a>
name="<em>bool_name</em>"
>[true | false]</bool>
</resources>
</pre>
</dd>
<dt>elements:</dt>
<dd>
<dl class="tag-list">
<dt id="bool-resources-element"><code><resources></code></dt>
<dd><strong>Required.</strong> This must be the root node.
<p>No attributes.</p>
</dd>
<dt id="bool-element"><code><bool></code></dt>
<dd>A boolean value: {@code true} or {@code false}.
<p class="caps">attributes:</p>
<dl class="atn-list">
<dt><code>name</code></dt>
<dd><em>String</em>. A name for the bool value. This will be used as the resource ID.</dd>
</dl>
</dd>
</dl>
</dd> <!-- end elements and attributes -->
<dt>example:</dt>
<dd>XML file saved at <code>res/values-small/bools.xml</code>:
<pre>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<bool name="screen_small">true</bool>
<bool name="adjust_view_bounds">true</bool>
</resources>
</pre>
<p>This application code retrieves the boolean:</p>
<pre>
Resources res = {@link android.content.Context#getResources()};
boolean screenIsSmall = res.{@link android.content.res.Resources#getBoolean(int) getBoolean}(R.bool.screen_small);
</pre>
<p>This layout XML uses the boolean for an attribute:</p>
<pre>
<ImageView
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:src="@drawable/logo"
android:adjustViewBounds="@bool/adjust_view_bounds" />
</pre>
</dd> <!-- end example -->
</dl>
<h2 id="Color">Color</h2>
<p>A color value defined in XML.
The color is specified with an RGB value and alpha channel. You can use a color resource
any place that accepts a hexadecimal color value. You can also use a color resource when a
drawable resource is expected in XML (for example, {@code android:drawable="@color/green"}).</p>
<p>The value always begins with a pound (#) character and then followed by the
Alpha-Red-Green-Blue information in one of the following formats:</p>
<ul>
<li>#<em>RGB</em></li>
<li>#<em>ARGB</em></li>
<li>#<em>RRGGBB</em></li>
<li>#<em>AARRGGBB</em></li>
</ul>
<p class="note"><strong>Note:</strong> A color is a simple resource that is referenced
using the value provided in the {@code name} attribute (not the name of the XML file). As
such, you can combine color resources with other simple resources in the one XML file,
under one {@code <resources>} element.</p>
<dl class="xml">
<dt>file location:</dt>
<dd><code>res/values/colors.xml</code><br/>
The filename is arbitrary. The {@code <color>} element's {@code name} will be used as the
resource ID.</dd>
<dt>resource reference:</dt>
<dd>
In Java: <code>R.color.<em>color_name</em></code><br/>
In XML: <code>@[<em>package</em>:]color/<em>color_name</em></code>
</dd>
<dt>syntax:</dt>
<dd>
<pre class="stx">
<?xml version="1.0" encoding="utf-8"?>
<<a href="#color-resources-element">resources</a>>
<<a href="#color-element">color</a>
name="<em>color_name</em>"
><em>hex_color</em></color>
</resources>
</pre>
</dd>
<dt>elements:</dt>
<dd>
<dl class="tag-list">
<dt id="color-resources-element"><code><resources></code></dt>
<dd><strong>Required.</strong> This must be the root node.
<p>No attributes.</p>
</dd>
<dt id="color-element"><code><color></code></dt>
<dd>A color expressed in hexadecimal, as described above.
<p class="caps">attributes:</p>
<dl class="atn-list">
<dt><code>name</code></dt>
<dd><em>String</em>. A name for the color. This will be used as the resource ID.
</dd>
</dl>
</dd>
</dl>
</dd> <!-- end elements and attributes -->
<dt>example:</dt>
<dd>XML file saved at <code>res/values/colors.xml</code>:
<pre>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="opaque_red">#f00</color>
<color name="translucent_red">#80ff0000</color>
</resources>
</pre>
<p>This application code retrieves the color resource:</p>
<pre>
Resources res = {@link android.content.Context#getResources()};
int color = res.{@link android.content.res.Resources#getColor(int) getColor}(R.color.opaque_red);
</pre>
<p>This layout XML applies the color to an attribute:</p>
<pre>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="@color/translucent_red"
android:text="Hello"/>
</pre>
</dd> <!-- end example -->
</dl>
<h2 id="Dimension">Dimension</h2>
<p>A dimension value defined in XML. A dimension
is specified with a number followed by a unit of measure.
For example: 10px, 2in, 5sp. The following units of measure are supported by Android:</p>
<dl>
<dt>{@code dp}</dt>
<dd>Density-independent Pixels - an abstract unit that is based on the physical density of the screen.
These units are relative to a 160 dpi screen, so one dp is one pixel on a 160 dpi screen. The ratio of
dp-to-pixel will change with the screen density, but not necessarily in direct proportion. The
compiler accepts both "dip" and "dp", though "dp" is more consistent with "sp".</dd>
<dt>{@code sp}</dt>
<dd>Scale-independent Pixels - this is like the dp unit, but it is also scaled by the user's font
size preference. It is recommend you use this unit when specifying font sizes, so they will be adjusted
for both the screen density and the user's preference.</dd>
<dt>{@code pt}</dt>
<dd>Points - 1/72 of an inch based on the physical size of the screen.</dd>
<dt>{@code px}</dt>
<dd>Pixels - corresponds to actual pixels on the screen. This unit of measure is not recommended because
the actual representation can vary across devices; each devices may have a different number of pixels
per inch and may have more or fewer total pixels available on the screen.</dd>
<dt>{@code mm}</dt>
<dd>Millimeters - based on the physical size of the screen.</dd>
<dt>{@code in}</dt>
<dd>Inches - based on the physical size of the screen.</dd>
</dl>
<p class="note"><strong>Note:</strong> A dimension is a simple resource that is referenced
using the value provided in the {@code name} attribute (not the name of the XML file). As
such, you can combine dimension resources with other simple resources in the one XML file,
under one {@code <resources>} element.</p>
<dl class="xml">
<dt>file location:</dt>
<dd><code>res/values/<em>filename</em>.xml</code><br/>
The filename is arbitrary. The {@code <dimen>} element's {@code name} will be used as the
resource ID.</dd>
<dt>resource reference:</dt>
<dd>
In Java: <code>R.dimen.<em>dimension_name</em></code><br/>
In XML: <code>@[<em>package</em>:]dimen/<em>dimension_name</em></code>
</dd>
<dt>syntax:</dt>
<dd>
<pre class="stx">
<?xml version="1.0" encoding="utf-8"?>
<<a href="#dimen-resources-element">resources</a>>
<<a href="#dimen-element">dimen</a>
name="<em>dimension_name</em>"
><em>dimension</em></dimen>
</resources>
</pre>
</dd>
<dt>elements:</dt>
<dd>
<dl class="tag-list">
<dt id="dimen-resources-element"><code><resources></code></dt>
<dd><strong>Required.</strong> This must be the root node.
<p>No attributes.</p>
</dd>
<dt id="dimen-element"><code><dimen></code></dt>
<dd>A dimension, represented by a float, followed by a unit of measurement (dp, sp, pt, px, mm, in),
as described above.
<p class="caps">attributes:</p>
<dl class="atn-list">
<dt><code>name</code></dt>
<dd><em>String</em>. A name for the dimension. This will be used as the resource ID.
</dd>
</dl>
</dd>
</dl>
</dd> <!-- end elements and attributes -->
<dt>example:</dt>
<dd>XML file saved at <code>res/values/dimens.xml</code>:
<pre>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="textview_height">25dp</dimen>
<dimen name="textview_width">150dp</dimen>
<dimen name="ball_radius">30dp</dimen>
<dimen name="font_size">16sp</dimen>
</resources>
</pre>
<p>This application code retrieves a dimension:</p>
<pre>
Resources res = {@link android.content.Context#getResources()};
float fontSize = res.{@link android.content.res.Resources#getDimension(int) getDimension}(R.dimen.font_size);
</pre>
<p>This layout XML applies dimensions to attributes:</p>
<pre>
<TextView
android:layout_height="@dimen/textview_height"
android:layout_width="@dimen/textview_width"
android:textSize="@dimen/font_size"/>
</pre>
</dl>
</dd> <!-- end example -->
</dl>
<h2 id="Id">ID</h2>
<p>A unique resource ID defined in XML. Using the name you provide in the {@code <item>}
element, the Android developer tools create a unique integer in your project's {@code
R.java} class, which you can use as an
identifier for an application resources (for example, a {@link android.view.View} in your UI layout)
or a unique integer for use in your application code (for example, as an ID for a dialog or a
result code).</p>
<p class="note"><strong>Note:</strong> An ID is a simple resource that is referenced
using the value provided in the {@code name} attribute (not the name of the XML file). As
such, you can combine ID resources with other simple resources in the one XML file,
under one {@code <resources>} element. Also, remember that an ID resources does not reference
an actual resource item; it is simply a unique ID that you can attach to other resources or use
as a unique integer in your application.</p>
<dl class="xml">
<dt>file location:</dt>
<dd><code>res/values/<em>filename.xml</em></code><br/>
The filename is arbitrary.</dd>
<dt>resource reference:</dt>
<dd>
In Java: <code>R.id.<em>name</em></code><br/>
In XML: <code>@[<em>package</em>:]id/<em>name</em></code>
</dd>
<dt>syntax:</dt>
<dd>
<pre class="stx">
<?xml version="1.0" encoding="utf-8"?>
<<a href="#id-resources-element">resources</a>>
<<a href="#id-item-element">item</a>
type="id"
name="<em>id_name</em>" />
</resources>
</pre>
</dd>
<dt>elements:</dt>
<dd>
<dl class="tag-list">
<dt id="integer-resources-element"><code><resources></code></dt>
<dd><strong>Required.</strong> This must be the root node.
<p>No attributes.</p>
</dd>
<dt id="integer-element"><code><integer></code></dt>
<dd>Defines a unique ID. Takes no value, only attributes.
<p class="caps">attributes:</p>
<dl class="atn-list">
<dt><code>type</code></dt>
<dd>Must be "id".</dd>
<dt><code>name</code></dt>
<dd><em>String</em>. A unique name for the ID.</dd>
</dl>
</dd>
</dl>
</dd> <!-- end elements and attributes -->
<dt>example:</dt>
<dd>
<p>XML file saved at <code>res/values/ids.xml</code>:</p>
<pre>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item type="id" name="button_ok" />
<item type="id" name="dialog_exit" />
</resources>
</pre>
<p>Then, this layout snippet uses the "button_ok" ID for a Button widget:</p>
<pre>
<Button android:id="<b>@id/button_ok</b>"
style="@style/button_style" />
</pre>
<p>Notice that the {@code android:id} value does not include the plus sign in the ID reference,
because the ID already exists, as defined in the {@code ids.xml} example above. (When you specify an
ID to an XML resource using the plus sign—in the format {@code
android:id="@+id/name"}—it means that the "name" ID does not exist and should be created.)</p>
<p>As another example, the following code snippet uses the "dialog_exit" ID as a unique identifier
for a dialog:</p>
<pre>
{@link android.app.Activity#showDialog(int) showDialog}(<b>R.id.dialog_exit</b>);
</pre>
<p>In the same application, the "dialog_exit" ID is compared when creating a dialog:</p>
<pre>
protected Dialog {@link android.app.Activity#onCreateDialog(int)}(int id) {
Dialog dialog;
switch(id) {
case <b>R.id.dialog_exit</b>:
...
break;
default:
dialog = null;
}
return dialog;
}
</pre>
</dd> <!-- end example -->
</dl>
<h2 id="Integer">Integer</h2>
<p>An integer defined in XML.</p>
<p class="note"><strong>Note:</strong> An integer is a simple resource that is referenced
using the value provided in the {@code name} attribute (not the name of the XML file). As
such, you can combine integer resources with other simple resources in the one XML file,
under one {@code <resources>} element.</p>
<dl class="xml">
<dt>file location:</dt>
<dd><code>res/values/<em>filename.xml</em></code><br/>
The filename is arbitrary. The {@code <integer>} element's {@code name} will be used as the
resource ID.</dd>
<dt>resource reference:</dt>
<dd>
In Java: <code>R.integer.<em>integer_name</em></code><br/>
In XML: <code>@[<em>package</em>:]integer/<em>integer_name</em></code>
</dd>
<dt>syntax:</dt>
<dd>
<pre class="stx">
<?xml version="1.0" encoding="utf-8"?>
<<a href="#integer-resources-element">resources</a>>
<<a href="#integer-element">integer</a>
name="<em>integer_name</em>"
><em>integer</em></integer>
</resources>
</pre>
</dd>
<dt>elements:</dt>
<dd>
<dl class="tag-list">
<dt id="integer-resources-element"><code><resources></code></dt>
<dd><strong>Required.</strong> This must be the root node.
<p>No attributes.</p>
</dd>
<dt id="integer-element"><code><integer></code></dt>
<dd>An integer.
<p class="caps">attributes:</p>
<dl class="atn-list">
<dt><code>name</code></dt>
<dd><em>String</em>. A name for the integer. This will be used as the resource ID.
</dd>
</dl>
</dd>
</dl>
</dd> <!-- end elements and attributes -->
<dt>example:</dt>
<dd>
<p>XML file saved at <code>res/values/integers.xml</code>:</p>
<pre>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<integer name="max_speed">75</integer>
<integer name="min_speed">5</integer>
</resources>
</pre>
<p>This application code retrieves an integer:</p>
<pre>
Resources res = {@link android.content.Context#getResources()};
int maxSpeed = res.{@link android.content.res.Resources#getInteger(int) getInteger}(R.integer.max_speed);
</pre>
</dd> <!-- end example -->
</dl>
<h2 id="IntegerArray">Integer Array</h2>
<p>An array of integers defined in XML.</p>
<p class="note"><strong>Note:</strong> An integer array is a simple resource that is referenced
using the value provided in the {@code name} attribute (not the name of the XML file). As
such, you can combine integer array resources with other simple resources in the one XML file,
under one {@code <resources>} element.</p>
<dl class="xml">
<dt>file location:</dt>
<dd><code>res/values/<em>filename</em>.xml</code><br/>
The filename is arbitrary. The {@code <integer-array>} element's {@code name} will be used as the
resource ID.</dd>
<dt>compiled resource datatype:</dt>
<dd>Resource pointer to an array of integers.</dd>
<dt>resource reference:</dt>
<dd>
In Java: <code>R.array.<em>string_array_name</em></code><br/>
In XML: <code>@[<em>package</em>:]array.<em>integer_array_name</em></code>
</dd>
<dt>syntax:</dt>
<dd>
<pre class="stx">
<?xml version="1.0" encoding="utf-8"?>
<<a href="#integer-array-resources-element">resources</a>>
<<a href="#integer-array-element">integer-array</a>
name="<em>integer_array_name</em>">
<<a href="#integer-array-item-element">item</a>
><em>integer</em></item>
</integer-array>
</resources>
</pre>
</dd>
<dt>elements:</dt>
<dd>
<dl class="tag-list">
<dt id="integer-array-resources-element"><code><resources></code></dt>
<dd><strong>Required.</strong> This must be the root node.
<p>No attributes.</p>
</dd>
<dt id="integer-array-element"><code><string-array></code></dt>
<dd>Defines an array of integers. Contains one or more child {@code <item>} elements.
<p class="caps">attributes:</p>
<dl class="atn-list">
<dt><code>android:name</code></dt>
<dd><em>String</em>. A name for the array. This name will be used as the resource
ID to reference the array.</dd>
</dl>
</dd>
<dt id="integer-array-item-element"><code><item></code></dt>
<dd>An integer. The value can be a referenced to another
integer resource. Must be a child of a {@code <integer-array>} element.
<p>No attributes.</p>
</dd>
</dl>
</dd> <!-- end elements -->
<dt>example:</dt>
<dd>XML file saved at <code>res/values/integers.xml</code>:
<pre>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<integer-array name="bits">
<item>4</item>
<item>8</item>
<item>16</item>
<item>32</item>
</integer-array>
</resources>
</pre>
<p>This application code retrieves the integer array:</p>
<pre>
Resources res = {@link android.content.Context#getResources()};
int[] bits = res.{@link android.content.res.Resources#getIntArray(int) getIntArray}(R.array.bits);
</pre>
</dd> <!-- end example -->
</dl>
<h2 id="TypedArray">Typed Array</h2>
<p>A {@link android.content.res.TypedArray} defined in XML. You can use
this to create an array of other resources, such as drawables. Note that the array
is not required to be homogeneous, so you can create an array of mixed resource types, but
you must be aware of what and where the data types are in the array so that you can properly obtain
each item with the {@link android.content.res.TypedArray}'s {@code get...()} methods.</p>
<p class="note"><strong>Note:</strong> A typed array is a simple resource that is referenced
using the value provided in the {@code name} attribute (not the name of the XML file). As
such, you can combine typed array resources with other simple resources in the one XML file,
under one {@code <resources>} element.</p>
<dl class="xml">
<dt>file location:</dt>
<dd><code>res/values/<em>filename</em>.xml</code><br/>
The filename is arbitrary. The {@code <array>} element's {@code name} will be used as the
resource ID.</dd>
<dt>compiled resource datatype:</dt>
<dd>Resource pointer to a {@link android.content.res.TypedArray}.</dd>
<dt>resource reference:</dt>
<dd>
In Java: <code>R.array.<em>array_name</em></code><br/>
In XML: <code>@[<em>package</em>:]array.<em>array_name</em></code>
</dd>
<dt>syntax:</dt>
<dd>
<pre class="stx">
<?xml version="1.0" encoding="utf-8"?>
<<a href="#array-resources-element">resources</a>>
<<a href="#array-element">array</a>
name="<em>integer_array_name</em>">
<<a href="#array-item-element">item</a>><em>resource</em></item>
</array>
</resources>
</pre>
</dd>
<dt>elements:</dt>
<dd>
<dl class="tag-list">
<dt id="array-resources-element"><code><resources></code></dt>
<dd><strong>Required.</strong> This must be the root node.
<p>No attributes.</p>
</dd>
<dt id="array-element"><code><array></code></dt>
<dd>Defines an array. Contains one or more child {@code <item>} elements.
<p class="caps">attributes:</p>
<dl class="atn-list">
<dt><code>android:name</code></dt>
<dd><em>String</em>. A name for the array. This name will be used as the resource
ID to reference the array.</dd>
</dl>
</dd>
<dt id="array-item-element"><code><item></code></dt>
<dd>A generic resource. The value can be a reference to a resource or a simple data type.
Must be a child of an {@code <array>} element.
<p>No attributes.</p>
</dd>
</dl>
</dd> <!-- end elements -->
<dt>example:</dt>
<dd>XML file saved at <code>res/values/arrays.xml</code>:
<pre>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<array name="icons">
<item>@drawable/home</item>
<item>@drawable/settings</item>
<item>@drawable/logout</item>
</array>
<array name="colors">
<item>#FFFF0000</item>
<item>#FF00FF00</item>
<item>#FF0000FF</item>
</array>
</resources>
</pre>
<p>This application code retrieves each array and then obtains the first entry in each array:</p>
<pre>
Resources res = {@link android.content.Context#getResources()};
TypedArray icons = res.{@link android.content.res.Resources#obtainTypedArray(int) obtainTypedArray}(R.array.icons);
Drawable drawable = icons.{@link android.content.res.TypedArray#getDrawable(int) getDrawable}(0);
TypedArray colors = res.{@link android.content.res.Resources#obtainTypedArray(int) obtainTypedArray}(R.array.icons);
int color = colors.{@link android.content.res.TypedArray#getColor(int,int) getColor}(0,0);
</pre>
</dd> <!-- end example -->
</dl>
<!-- TODO
<h2>Styleable Attribute</h2>
<dl class="xml">
<dt>syntax:</dt>
<dd>
<pre class="stx">
</pre>
</dd>
<dt>file location:</dt>
<dd><code>res/</code></dd>
<dt>compiled resource datatype:</dt>
<dd>Resource pointer to a {@link android.view.Menu} (or subclass) resource.</dd>
<dt>resource reference:</dt>
<dd>Java: <code>R.</code><br/>
XML:
</dd>
<dt>elements and attributes:</dt>
<dd>
<dl class="attr">
<dt><code></code></dt>
<dd></dd>
<dt><code></code></dt>
<dd>Valid attributes:
<dl>
<dt><code></code></dt>
<dd>
</dd>
<dt><code></code></dt>
<dd>
</dd>
</dl>
</dd>
</dl>
</dd>
<dt>example:</dt>
<dd>
<dl>
<dt>XML file saved at <code>res/</code>:</dt>
<dd>
<pre>
</pre>
</dd>
<dt>Java code :</dt>
<dd>
<pre>
</pre>
</dd>
</dl>
</dd>
<dt>see also:</dt>
<dd>
<ul>
<li></li>
</ul>
</dd>
</dl>
-->
|