Android 调用资源字符串的几种方法

在 Layout XML 调用字符串资源:

<TextView

    android:layout_width="fill_parent"

    android:layout_height="wrap_content"

    android:text="@string/hello" />

 

在 Activity 获取字符串资源:

this.getString(R.string.hello);

 

从 Context 获取字符串资源:

context.getString(R.string.hello);

 

从 Application 获取字符串资源:

application.getString(R.string.hello);

// TBKTApplication.getInstance().getString(R.string.api_url)

posted @ 2015-10-12 16:42  weiokx  阅读(1041)  评论(0编辑  收藏  举报