Define integers

Download android eBook

Example

Integers are typically stored in a resource file named integers.xml, but the file name can be chosen arbitrarily. Each integer is defined by using an <integer> element, as shown in the following file:

res/values/integers.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <integer name="max">100</integer>
</resources> 

Integers can now be referenced in XML with the syntax @integer/name_of_the_integer, as shown in the following example:

<ProgressBar
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:max="@integer/max"/>

Stats

Contributors: 2
2017-08-02
Licensed under: CC-BY-SA

Not affiliated with Stack Overflow
Rip Tutorial: info@zzzprojects.com

Download eBook