一、在程序中获取string.xml中字符串和数值
<resources>
<string name="hello">Hello World,MainActivity!</string>
<stringname="app_name">TestExample01</string>
</resources>
<string name="hello">Hello World,MainActivity!</string>
<stringname="app_name">TestExample01</string>
</resources>
1.在Activity中使用:
StringappName=(String) this.getResources().getText(R.string.app_name);
Log.i("test", "appName="+appName);
或者:
String appName=(String) this.getResources().getString(R.string.app_name);
Log.i("test", "appName="+appName);
2.我经常在activity_main
<!-- 手机号码标签 -->
<TextView
android:id="@+id/textviewnumber"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/app_name " />