如何通过 Simple Spinner Item C# 使用小数列表填充适配器

How to populate adapter with a List of decimal through Simple Spinner Item C#

如何通过 Simple Spinner Item 使用十进制列表填充适配器?

   private async void GetCheckUserStore(string uname) {

        StoreNameRepository<List<decimal?>> repo = new StoreNameRepository<List<decimal?>>();
        List<decimal?> result = await repo.GetCheckUserStore(uname);

        if(result!= null) {

         //   ArrayAdapter<string> adapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleSpinnerItem, Convert.ToInt32(result));
         //spinner_storelist.Adapter = adapter;

        }

我会将十进制值列表转换为字符串值列表,然后使用相同的内容,如下所示:

private async void GetCheckUserStore(string uname) {

    StoreNameRepository<List<decimal?>> repo = new StoreNameRepository<List<decimal?>>();
    List<decimal?> result = await repo.GetCheckUserStore(uname);
    List<string> stringResult = result.Select(x => x.ToString()).ToList();
    if(result!= null) {

     ArrayAdapter<string> adapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleSpinnerItem, stringResult);
     spinner_storelist.Adapter = adapter;

    }

不要忘记添加以下命名空间:

using System.Linq;