snip-code from values/string.xml:
<array name="categories">
    <item name="today">Today</item>
    <item name="life">Life</item>
    <item name="corner">Corner</item>
    <item name="banks">Banks</item>
    <item name="it">IT</item>
    <item name="fun">Fun</item>
</array>
snip-code from layout/main.xml:
<Button
    android:id="@+id/today"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textSize="8sp"
    android:text="@array/categories"
    />
Is it possible to assign a label-name to a Button with id=today directly from values/string.xml using string-array with name=categories and specific item, in this case - today?
See the selected answer here: Android - reference a string in a string array resource with xml.
According to that answer, have to do something like this:
<string name="earth">Earth</string>
<string name="moon">Moon</string>
<string-array name="system">
    <item>@string/earth</item>
    <item>@string/moon</item>
</string-array>
Then you would simply do:
  <Button ....
  android:text="@string/earth" />
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With