2016-07-28 16 views
0

我在strings.xml一個字符串數組,看起來像這樣:充分利用的strings.xml一個字符串數組中xamarin的Android

<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

你的錯誤是什麼?或者如果沒有錯誤,問題是什麼?頁面爲空? – Jack

+0

原來IDE剛剛出錯,很好.................. – Reaper9806

回答

1

我會做這樣的:

字符串[]頁= getResources()getStringArray(R.array.helpPages);

0

問題問Xamarin.Android,但接受的答案語法是Java,所以這裏是C#語法(Xamarin方式):

var items = Resources.GetStringArray(Resource.Array.helpPages); 

您可以通過使用forforeach訪問每個項目。例如:

foreach (var item in items) 
{ 
    // do whatever you want with item 
} 
相關問題