Android-定义和获取字符串资源

resource->values->strings.xml里定义字符串

  定义单字符串:

<string name="app_name">abc123</string>

  定义字符串数组:

<string-array name="map_style_array">
        <item>MAPBOX_STREETS</item>
        <item>OUTDOORS</item>
        <item>SATELLITE</item>
        <item>SATELLITE_STREETS</item>
        <item>LIGHT</item>
        <item>DARK</item>
        <item>TRAFFIC_DAY</item>
        <item>TRAFFIC_NIGHT</item>
    </string-array>

   字符串数组id:

    r.array.xxx 

  字符串id:

    r.string.xxx

  字符串数组取值:

    String strs [] = getResource().getStringArray(int id)

  字符串取值:

    String str = getResource().getString(int id);

posted @ 2023-07-28 09:59  remix_alone  阅读(149)  评论(0)    收藏  举报