我在同一个 Activity 中有一个微调器和一个 ListView 。 ListView 加载了项目列表。我希望当用户单击微调器中的项目时, ListView 将被清除,并且新的 ListView 将根据微调器中选择的项目加载
setListAdapter(new ArrayAdapter<String>(this, R.layout.listviewxml, video));
ListView lv=getListView();
lv.setTextFilterEnabled(true);
请告诉我怎么做?
我无法清除 ListView
最佳答案
如果您已将列表或数组传递给适配器,则
// Clear collection..
collection.clear();
// Add data to collection..
collection.add();
// Refresh your listview..
listview.getAdapter().notifyDataSetChanged();
(这些代码就像伪代码,您的语法可能会有所不同)
关于android - 如何清除 Android ListView 并用新数据填充它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8310851/