gpt4 book ai didi

android - Espresso : How to use R. androidTest文件夹的字符串资源

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:51:36 25 4
gpt4 key购买 nike

我想将数据放入 androidTest/res/values/string.xml 文件夹的 xml 文件中。我已经创建了包含以下内容的文件 test.xml。

<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="test">hello</string>
</resources>

当我尝试通过 R.string.test 访问现场测试时。它不可访问并显示“无法解析符号测试”。有人可以在这里给我建议吗。

最佳答案

这是你的做法:

import com.my.example.test.R;

Resources resources = InstrumentationRegistry.getContext().getResources();
String terms = resources.getString(R.string.test);

关于android - Espresso : How to use R. androidTest文件夹的字符串资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36955608/

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