现在的位置: 首页 > 综合 > 正文

strings.xml中定义字符串的使用方法

2019年06月01日 ⁄ 综合 ⁄ 共 249字 ⁄ 字号 评论关闭

1. 在AndroidManifest.xml与layout里:

android:text="@string/resource_name"


2.在activity里: 

this.getString(R.string.resource_name)


3.在其他地方如 ListAdapter,(必须有Context或Applicaton) 

context.getString(R.string.resource_name)

application.getString(R.string.resource_name)

抱歉!评论已关闭.