创建本地路径和String文件
Android app在运行时,会根据手机的设置来加载不同的String文件
创建不同的values文件夹和strings.xml文件
MyProject/ res/ values/ strings.xml values-es/ strings.xml values-fr/ strings.xml
在代码中引用String资源:
// Get a string resource from your app's Resources
String hello = getResources().getString(R.string.hello_world);
// Or supply a string resource to a method that requires a string
TextView textView = new TextView(this);
textView.setText(R.string.hello_world);
在XML中引用String资源:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />