0

How to programmatically add item to strings.xml for spinner's string-array?

<Spinner
            android:id="@+id/tags"
            android:spinnerMode="dialog"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:entries="@array/tags" />    

strings.xml

<string-array name="tags">
    <item>item1</item>
    <item>item2</item>
    <item>item3</item>
    <item>item4</item>
</string-array>>
General Grievance
  • 4,555
  • 31
  • 31
  • 45
Stdio
  • 1
  • 2
  • 2
    Possible duplicate of [How can I add items to a spinner in Android?](https://stackoverflow.com/questions/5241660/how-can-i-add-items-to-a-spinner-in-android) – Stephen M -on strike- Nov 30 '18 at 19:36

3 Answers3

1

You can't add data to application resources programmatically. Resources are part of compiled, packed and signed APK package and therefore can't be modified. What are you trying to achieve?

d.aemon
  • 761
  • 1
  • 7
  • 20
1

You can't add things to resources programmatically. But a Spinner doesn't need to go off a resource file. Use an in memory list of items, and modify that.

Gabe Sechan
  • 90,003
  • 9
  • 87
  • 127
0

If try to add data in spinner programmtically.

there is only one way use database like #firebase which update realtime data.

"without database it not possible."

Kalpesh A. Nikam
  • 324
  • 3
  • 10