user915267 user915267 -4 years ago 121
Android Question

Access string.xml to java code in Android

I tried to access data present in

res/values/string.xml
to
Activity class
in Android, but I'm not able to access it.
If anybody knows help me.

Answer Source

This is present in res/values/string.xml

<string-array name="planet"> 
    <item>Mercury<item>
    <item>Venus</item>
    <item>Earth</item>
    <item>Mars</item>
</string-array>

This code to be placed in res/layout/main.xml and remove default widgets present in main.xml.

<ListView android:id="@+id/planet"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:entries="@array/planet"/>
</LinearLayout>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download