【发布时间】:2018-05-11 07:46:08
【问题描述】:
我正在 Xamarin.Android 中开发一个应用程序。在这里,我使用带有 baseadapter 的 listview 来附加联系人列表。现在,一旦从数据库滚动到列表视图的末尾,我需要追加项目。我的意思是这个概念就像“加载更多项目”。起初,我通过在滚动到列表视图末尾时重新创建它来将项目添加到适配器。但我从链接 Load More Item in lazy adapter and listview 了解到这不是最佳方式。 我的代码如下,
allContactsList -> 从数据库中获取项目
适配器 -> 我的自定义适配器
if (allContactsList != null && allContactsList.Count() > 0)
{
if(adapter == null)
adapter = new AllContactsListAdapter(this, allContactsList);
else
{
//Stucks here. I can't append to adapter
}
adapter.NotifyDataSetChanged();
listView.Adapter = adapter;
}
如何将新项目附加到 Xamarin.Android 中的适配器?
【问题讨论】: