snip- code从值/ string.xml
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从布局/ main.xml中
<Button
android:id="@+id/today"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="8sp"
android:text="@array/categories"
/>
是否有可能一个标签名称分配给一个按钮 ID =今天直接从值/ string.xml 使用字符串数组的名称=类别和具体项目,在这种情况下? - 今天
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?
在这里看到所选答案:Android - 引用字符串中使用XML 一个字符串数组资源。
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" />