呼吁notifyDataSetChanged上ListAdapter [英] Calling notifyDataSetChanged on a ListAdapter
问题描述
我有一个 ListAdapter
,如下所示:
setListAdapter(new ArrayAdapter<String>(DeleteMenu.this,
android.R.layout.simple_list_item_1,
classes));
我想一个 onListItemClick()
函数中调用 notifyDataSetChanged()
就可以了。我已经尝试了几种不同的方式,看着类似的问题在这里StackOverflow上,但我仍然无法搞清楚。
I am trying to call notifyDataSetChanged()
on it within an onListItemClick()
function. I've tried a few different ways and looked at similar questions here on StackOverFlow but I still can't figure it out.
有人可以帮助?
编辑:我应该更清楚,我没有得到一个错误,我根本不知道什么叫功能 notifyDataSetChanged()
的方法。我一定要分配我的 ListAdapter
给一个变量,并调用它像 var.notifyDataSetChanged()
I should be more clear, I'm not getting an error, I simply don't know what to call the function notifyDataSetChanged()
method on. Do I have to assign my ListAdapter
to a variable and call it like var.notifyDataSetChanged()
?
推荐答案
您应该叫 notifyDataSetChanged
的适配器。
Adapter adapter = new Adapter();
ListView list = (ListView) findViewById(R.id.listview);
list.setAdapter(adapter);
adapter.notifyDataSetChanged();
这篇关于呼吁notifyDataSetChanged上ListAdapter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!