我在导入字符串数组时遇到问题!
当我尝试下面的代码时, Spinners 保持为空并且不加载数组字符串值。这是我使用的代码:
//Fill CoinSpinner
Spinner CoinSpinner = FindViewById<Spinner>(Resource.Id.CoinSpinner);
CoinSpinner.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs>(CoinSpinner_ItemSelected);
ArrayAdapter<String> CoinSpinnerAdapter = new ArrayAdapter<String>(this, Resource.Array.coin_array, Android.Resource.Layout.SimpleSpinnerItem);
//ArrayAdapter CoinSpinnerAdapter = ArrayAdapter.CreateFromResource(this, Resource.Array.coin_array, Android.Resource.Layout.SimpleSpinnerItem);
CoinSpinnerAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
CoinSpinner.Adapter = CoinSpinnerAdapter;
我想从 Resources/values/String.xml 导入一个字符串数组。我做错了什么?
编辑:
这是 String.xml 文件:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">TestApp</string>
<string name="coins_prompt">Coin:</string>
<string-array name="coin_array">
<item>EUR</item>
<item>USD</item>
</string-array>
</resources>
12345678_0001
相关分类