Xamarin ArrayAdapter不适用于int []

时间:2018-02-19 18:55:21

标签: c# listview xamarin xamarin.android android-arrayadapter

我有一个带有数组适配器的listview。我需要在listview中显示一个int [],但它只适用于string []。有什么想法吗?

这是我的代码:

int[] a = new int[20];

ArrayAdapter adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleListItem1, a[i]);

ListView list = FindViewById<ListView>(Resource.Id.listView1);
list.Adapter = adapter;

int i进入一个周期。

2 个答案:

答案 0 :(得分:1)

您可以转换为字符串数组

string[] result = a.Select(x=>x.ToString()).ToArray();

ArrayAdapter adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleListItem1, result[i]);

答案 1 :(得分:0)

使用基于function TotalSales() { /* @OnlyCurrentDoc */ //Get Current Google Sheet, Get Active Sheet Tab. //finds current active sheet var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); //find current active cell var cell = ss.getActiveCell(); //find row number of active cell var row = cell.getRow(); //defines a variable to the cell adjacent to where "vendio" is var H_cell = ss.getRange(row,8); //gets value of Column H cell adjacent to where "vendio" is var H_value = H_cell.getValue(); //find the range of N5 cell var N5_cell = ss.getRange("N5"); //Gets value inside N5 Range var N5_value = N5_cell.getValue(); if(cell.getValue() == "vendio") { //cell.getValue() gets value in the active cell sum_value = H_value + N5_value; // sums value of adjacent cell to vendio and value of an cell thats keeping count N5_cell.setValue(sum_value); //sets N5 value to the sum of N5 and H(row) } else { N5_cell.setValue(N5_value); }; } function onEdit(){ TotalSales(); }; 的集合来实现自动C#/ Java类型转换

IList