android中获取res的字符串

来源:互联网 发布:日语等级考试分数算法 编辑:程序博客网 时间:2024/05/29 15:26

string.xml如下:

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

<resources>
    <string name="hello">Hello World, Login!</string>
    <string name="app_name">数据中心移动办公系统</string>
    <string name="tvUid">请输入密码:</string>
    <string name="welcome">欢迎您登录数据中心OA系统!</string>

</resources>

java中代码获得:

txtWelcome=(TextView)findViewById(R.id.txtWelcome);
txtWelcome.setPadding(0,5, 0, 5);
String strWelcome=getString(R.string.welcome).toString(); 
txtWelcome.setText("福"+strWelcome);