Strings in android

avatar

NaN years ago

String resources are a simple concept of android, It is widely used to display text on the screen and also style the text. I hope you will not confuse string resources with string datatype, both of these are totally different concepts.


There are three types of string resources in android:

1) String

- XML resource that provides a single string.

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string
        name="string_name"
        >text_string</string>
</resources>


2) String Array

- XML resource that provides an array of strings.

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string-array
        name="string_array_name">
        <item
            >text_string</item>
    </string-array>
</resources>


3) Quantity Strings (Plurals)

- XML resource that carries different strings for pluralization.

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <plurals
        name="plural_name">
        <item
            quantity=["zero" | "one" | "two" | "few" | "many" | "other"]
            >text_string</item>
    </plurals>
</resources>


A blog can not teach you all about string resources and their types. To learn completely about this topic, please use the resources provided by Neuton.

approvedApproved by experts
Advance Topics

Neuton's Mission

We are a team of young and enthusiastic people who are passionate about education and want to help students to learn the skills they need to succeed in life. If you want to support us, please join our community.

phonephonephonephonemail