Xamarin Android:如何在ListView中显示/绑定列表?

问题描述 投票:-1回答:1

我尝试了几种方法将List元素绑定到ListView,但是没有成功。我总是收到错误消息“无法转换列表

List<string> numbersListString= new List<string> {
        "One",
        "Two",
        "Three",
        "Four",
        "Five",
        "Six",
    };

listView numbersListView = root.FindViewById<ListView>(Resource.Id.numbers);


var adapter = new ArrayAdapter<string>(Context,
               Android.Resource.Layout.ActivityListItem, numbersListString);

adapter.AddAll(Android.Resource.Layout.ActivityListItem);
            numbersListView.Adapter = adapter;


c# android visual-studio listview xamarin.android
1个回答
0
投票

原因:

© www.soinside.com 2019 - 2024. All rights reserved.