我有一个ListView,它的项目是从Api调用中获取的。然后添加另一项,将其发送到api进行添加。我想用刚才添加的值更新现有列表。
我正在做这样的事情:
itemList = dataAgent.GetItemList(some params);
cAdapter = new ItemsListAdapter(this, itemList);
lvItems.Visibility = ViewStates.Visible;
lvItems.Adapter = cAdapter;
SetListViewHeightBasedOnChildren(lvItems);
}
btnItemComment.Click += btnItemComment_Click;
void btnItemComment_Click(object sender, EventArgs e)
{
string itemsText = editComments.Text.ToString().Trim();
if(string.IsNullOrEmpty(itemsText))
{
CreateAndShowAlert(this, "", "Please enter a text");
}
else
{
var status = dataAgent.PostItem (Some more params);
if(status)
{
cAdapter.NotifyDataSetChanged();
}
}
}但是ListView不会被刷新。还有什么我需要做的吗?任何帮助都将不胜感激
发布于 2015-12-28 17:33:47
再次设置适配器,然后添加NotifyDataSetChanged:-
cAdapter =新的ItemsListAdapter(this,itemList);
cAdapter.NotifyDataSetChanged();
https://stackoverflow.com/questions/34490832
复制相似问题