首页 > 移动平台 > 详细

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

时间:2015-10-12 17:09:17      阅读:280      评论:0      收藏:0      [点我收藏+]

在 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)

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

原文:http://www.cnblogs.com/weiok/p/4872102.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!