[英]C# Xamarin.forms ListView population listview with list<string>
I am trying to parse a string of events into a list EventsList, then populate the fields in my listview (title, location, time, and date) with the correct strings from EventList. 我试图将事件字符串解析为列表EventsList,然后使用EventList中的正确字符串填充列表视图中的字段(标题,位置,时间和日期)。 The problem I have run into now is that the method used to populate EventsList is returning something that is no where to be found in my string. 我现在遇到的问题是,用于填充EventsList的方法返回的内容在我的字符串中找不到。 The string displayed from EventsList is: 从EventsList显示的字符串是:
System.Collections.GenericList'1[System.String] System.Collections.GenericList'1 [System.String]
If anyone could help me figure out why it is returning that it would be much appreciated - or if there is a better strategy to do this please enlighten me. 如果有人能帮助我弄清楚为什么会回来,将不胜感激-或有更好的策略来解决这个问题,请赐教。
List<string> EventsList = new List<string>();
EventsList = EventDetails(EventsList);
List<string> EventDetails(List<string> arEvents)
{
int indexNum = 67;
string events = GetEvents();
//while (indexNum <= 78)
//{
int index1 = (events.IndexOf(indexNum.ToString())) + 2;
int commaIndex = events.IndexOf(",");
if ((commaIndex - index1) <= 0)
{
string Title = events.Substring(index1, 10);
indexNum++;
}
else
indexNum++;
// }
Title = events.Substring(index1, 10);
arEvents.Add(Title);
return arEvents;
}
MainListView.ItemsSource = new List<APBEvent>
{
new APBEvent()
{
EventTitle = GetEvents(),
EventLocation = "line break",
EventTime = EventsList.ToString(),
EventDate = "5/11/18",
},
};
EventsList.ToString()
EventList is list<string>
and you can not convert list
to string
. EventList是list<string>
,您不能将list
转换为string
。
If you want to convert list<string>
contents to string
then you can join the contents by using string.join
如果要将list<string>
内容转换为string
则可以使用string.join
内容
string.join(",",EventList);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.