• Latest Code...

    Read String and string array value from string.xml in android?

    A string resource provides text strings for your application with optional text styling and formatting. There are three types of resources that can provide your application with strings:
    XML resource that provides a single string.
    String Array
    XML resource that provides an array of strings.
    Quantity Strings (Plurals)
    XML resource that carries different strings for pluralization.

    All strings are capable of applying some styling markup and formatting arguments. For information about styling and formatting strings, see the section about Formatting and Styling.


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

    getting string like this on activity:

    String mess = getResources().getString(R.string.string_name);

    String Array:

    <string-array name="tabs_names"> 
    <item>My Tab 1</item>
    <item>My Tab 2</item>

    getting string array like this on activity:

    String[] tab_names = getResources().getStringArray(R.array.tab_names);

    Happy Coding!!

    1 comment:

    1. The great service in this blog and the nice technology is visible in this blog. I am really very happy for the nice approach is visible in this blog and thank you very much for using the nice technology in this blog

      Android Online Training



    Most recent Elastic Search tutorials for beginner, intermediate and advance level developer, Yubraj Pokharel, in CodingWorkspace