的getString()和getResources.getString之间差() [英] Difference between getString() and getResources.getString()

查看:1616
本文介绍了的getString()和getResources.getString之间差()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到活动类有两个不同的方法来得到一个字符串资源。 这可以通过使用

I noticed that the Activity class has two different methods to get a String resource. This is possible by using:

  • 的getString(INT渣油):返回一个本地化的字符串从应用程序的包的默认字符串表

  • getString(int resId): Return a localized string from the application's package's default string table.

getResources()的getString(INT ID):返回与特定的资源ID关联的字符串值。任何样式的文本信息将被剥离。

getResources().getString(int id): Returns the string value associated with a particular resource ID. It will be stripped of any styled text information.

我不明白什么是两种方法之间的差异。谁能告诉我?

I don't understand what's the difference between both methods. Can somebody tell me?

推荐答案

他们是一样的<一个href="http://grep$c$c.com/file/repository.grep$c$c.com/java/ext/com.google.android/android/1.6_r2/android/content/Context.java#Context.getString%28int%29"><$c$c>Activity.getString(int)正是这么做的:

They are the same as Activity.getString(int) does exactly that:

 public final String getString(int resId) {
     return getResources().getString(resId);
 }

这篇关于的getString()和getResources.getString之间差()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆