的getString()和getResources.getString之间差()

编程入门 行业动态 更新时间:2024-10-23 21:29:21
本文介绍了的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?

推荐答案

他们是一样的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之间差()

本文发布于:2023-11-10 06:24:57,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1574600.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:getString   getResources

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!