[url]http://www.cnblogs.com/bobli/archive/2011/06/04/2072942.html[/url]
字符串资源的定义
文件路径:res/values/strings.xml
[color=darkblue]字符串资源定义示例[/color]:
[color=darkblue]字符串资源的调用[/color]
在 Layout XML 调用字符串资源:
在 Activity 获取字符串资源:
从 Context 获取字符串资源:
从 Application 获取字符串资源:
参考:
String Resources [url]http://developer.android.com/guide/topics/resources/string-resource.html[/url]
字符串资源的定义
文件路径:res/values/strings.xml
[color=darkblue]字符串资源定义示例[/color]:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello!</string>
</resources>
[color=darkblue]字符串资源的调用[/color]
在 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)
参考:
String Resources [url]http://developer.android.com/guide/topics/resources/string-resource.html[/url]