zoukankan      html  css  js  c++  java
  • 调用字符串资源的几种方法

    字符串资源的定义
    文件路径:res/values/strings.xml
    字符串资源定义示例:

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
    <string name="hello">Hello!</string>
    </resources>


    字符串资源的调用

    在 Layout XML 调用字符串资源:
    <TextView
       
    android:layout_width="fill_parent"
        android:layout_height
    ="wrap_content"
        android:text
    ="@string/hello"
    />


    在 Activity 获取字符串资源:

    this.getString(R.string.hello)


    从 Context 获取字符串资源:

    context.getString(R.string.hello)


    从 Application 获取字符串资源:

    application.getString(R.string.hello)

    ----以上转自: http://www.ixueyun.com/community/forum-redirect-tid-1209-goto-lastpost.html

  • 相关阅读:
    OD 实验(十三)
    第一个 Windows 界面程序
    C 语言
    C 语言
    OD 实验(十二)
    PowerShell 常用命令
    OD 实验(十一)
    OD 实验(十)
    redis
    memcached缓存系统
  • 原文地址:https://www.cnblogs.com/newlooker/p/3001708.html
Copyright © 2011-2022 走看看