Create string array in android in string.xml file

Locate string.xml file in android project.

String.xml file is used to save static string values on android app project. Because there are so much similar textView text, button name text, edittext hint text on any app and if you don’t put similar text into string.xml file then you have to repeat it again and again. After saving text strings into string you can all them any where in whole application with define name. So here is the complete step by step tutorial for Create string array in android in string.xml file.

How to Create string array in android in string.xml file.

1. Locate your string.xml file in your project.

locate strings xml file in eclipse

2. Double click on it to open in editor windows.Below is the example of string array.

 <string-array name="mca_class">
 <item>I Sem</item>
 <item>II Sem</item>
 <item>III Sem</item>
 <item>IV Sem</item>
 <item>V Sem</item>
 <item>VI Sem</item>
 </string-array>

On above example string array is start using string-array tag and name=” mca_class ” is the name of array. With the use of this name you can call this array into whole application at any place. <item> is the list items you can write your own list items on this list.

Complete code of string.xml file including string array.

<?xml version="1.0" encoding="utf-8"?>
<resources>

 <string name="app_name">ListViewSetArray</string>
 <string name="hello_world">Hello world!</string>
 <string name="action_settings">Settings</string>
 
 <string-array name="mca_class">
 <item>I Sem</item>
 <item>II Sem</item>
 <item>III Sem</item>
 <item>IV Sem</item>
 <item>V Sem</item>
 <item>VI Sem</item>
 </string-array>
 
</resources>

Screenshot:

Create string array in android in string.xml file

Leave a Reply

Your email address will not be published. Required fields are marked *