获取string.xml中的字符

在activity里:

方法一:this.getString(R.string.resource_name);

方法二:getResources().getString(R.string.resource_name);

在其他java文件(必须有Context或aplication)

方法一: context.getString(R.string.resource_name);

方法二: application.getString(R.string.resource_name);

备注:如何获取aplication

<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:name="com.e.e.App"
>

public class App extends Application{
public static App app;
@Override
public void onCreate() {
// Todo Auto-generated method stub
super.onCreate();
app = this;

}

}

使用的时候App.app.getString(R.string.resource_name);

相关文章

php输出xml格式字符串
J2ME Mobile 3D入门教程系列文章之一
XML轻松学习手册
XML入门的常见问题(一)
XML入门的常见问题(三)
XML轻松学习手册(2)XML概念