0

$

<string name="app_name">demoMark</string>
<string name="action_settings">Settings</string>
<string name="hello_world">Hello world!</string>
<string name="spinner_header">Group Mate</string>
<string-array name="demo_name">
    <item>Product Amount</item>
    <item>1</item>
    <item>2</item>
    <item>3</item>
</string-array>

$

ArrayAdapter<CharSequence> adapteradapter = ArrayAdapter.createFromResource(this, R.array.demo_name, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); itemAmount.setAdapter(adapter);

here is the screenshot with arrayadapter here is the screenshot

Is there anyway that i can implement a loop in the string array in the String.XML ? it will be so helpful if anyone help me out with this.

Muhtadi Akif
  • 147
  • 1
  • 2
  • 7

2 Answers2

0

You can't do a loop in xml directly. Use an external script to generate your xml is an alternative way to do what you need...

Médéric
  • 938
  • 4
  • 12
0

As far as I know, it's unable to do that as it does not support xsd. You can read related discussion at here.

To parse XML in your way, I recommend Simple library to process xml data. This library reads XML data and creates into objects (so called deserialization) for you.

The tutorial at above link will give you enough examples, but you might need to do many trial-and-error in order to reflects xml structure to object hierarchy.

Youngjae
  • 24,352
  • 18
  • 113
  • 198