gpt4 book ai didi

android - 按名称获取字符串资源

转载 作者:行者123 更新时间:2023-11-30 04:18:25 26 4
gpt4 key购买 nike

我看过几个关于这个问题的话题,但我不知道为什么它们对我不起作用。这里是短代码:

//This doesn't work. I'm getting a 0 id
id=getResources().getIdentifier("q1", "id", getPackageName());

//This retrieves the string correctly (just to prove the string is called q1
String str=getResources().getString(R.string.q1);

我唯一能想到的是包名有问题,但看起来没问题。

有什么帮助吗?

最佳答案

应该是下面的吗?

 id=getResources().getIdentifier("q1", "string", getPackageName());

关于android - 按名称获取字符串资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9637515/

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