I would like to dynamically populate a drop down list . I would make a request to a server , get my data from there and according to my data ( for example I’ll take some ids) I would like to make the list bigger/ smaller. The example that I found on developer.android was a static one , since the names in the list were written in the strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="planet_prompt">Choose a planet</string>
<string-array name="planets_array">
<item>Mercury</item>
<item>Venus</item>
<item>Earth</item>
<item>Mars</item>
<item>Jupiter</item>
<item>Saturn</item>
<item>Uranus</item>
<item>Neptune</item>
</string-array>
</resources>
Full code here.
You can also set a particular item to be selected using:
EDIT :
You can also use your custom xml file to show spinner item,like-