我在strings.xml
中有一个字符串数组,如下所示:
<string-array name="helpPages">
<item>Hello, I am DOS-bot, and I will guide you through this game.</item>
<item>In this game you will learn how to use a computer terminal or console.
This is an important tool for dealing with technical problems on your computer.</item>
<item>For the common user, the terminal can be useful for figuring out problems
related to Internet connectivity, corrupted or damaged files and many more. </item>
</string-array>
我想在我的一项活动中访问它。
我目前正在做以下事情:
String[] pages = GetStringArray(Resource.Array.helpPages);
但它没有用。
答案 0 :(得分:1)
我会这样做:
String [] pages = getResources()。getStringArray(R.array.helpPages);
答案 1 :(得分:0)
有关Xamarin.Android
的问题,但接受的答案语法是Java
,所以这里是C#
语法( Xamarin方式):
var items = Resources.GetStringArray(Resource.Array.helpPages);
您可以使用for
或foreach
访问每个项目。对于前:
foreach (var item in items)
{
// do whatever you want with item
}