How can define two dimension string array in android resource? -
i wish fill in spinner control msgname field, , msgvalue when select item of spinner. write following code.but don't think it's code, there better code? need define 2 dimension string array app? how can do? thanks!
<?xmlversion="1.0"encoding="utf-8"?> <resources> <string-arrayname="msgname"> <item>inbox</item> <item>sent</item> </string-array> <string-arrayname="msgvalue"> <item>content://sms/inbox</item> <item>content://sms/sent</item> </string-array> </resources>
i want explicitly associate each name it's value, instead of having them in same position in 2 separate arrays.
there's @ least couple of ways accomplish this.
- use sort of separator concatenate name , value in same item: e.g.:
<string-array name="message">
<item>inbox|content://sms/inbox</item>
<item>sent|content://sms/sent</item>
</string-array>
- create custom xml resource, e.g. res/values/message-list.xml:
<messages>
<message name="inbox">content://inbox</message>
<message name="sent">content://sent</message>
</messages>
of course, either way, you're going have process contents , create spinneradapter - in first case, you'll have split entries, , in second case, you'll have parse xml.
Comments
Post a Comment