gpt4 book ai didi

android - 将字符串资源放入android中的包中

转载 作者:行者123 更新时间:2023-11-29 14:20:09 24 4
gpt4 key购买 nike

我有以下问题

Bundle bundle = new Bundle();
bundle.putString("url", "someUrl");

这很好用。但是

bundle.putString("title", R.string.titleForUrl);

Eclipse 注意到 R.string.titleForUrl 是一个 int 但应该是 string。但是 R.string.titleForUrl 不是一个字符串吗?

我该如何解决这个问题?

最佳答案

R.string.titleForUrls 是一个整数,它是字符串表中的资源标识符。

要获取字符串,您需要调用 context.getString(R.string.titleForUrls) 从资源中加载字符串。

因此,如果您希望存储字符串,那么您可以传递加载的字符串或 int,然后在您从另一端的包中获取 int 时加载。

关于android - 将字符串资源放入android中的包中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8386170/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com