这是我使用自定义 Listview 适配器所遵循的教程。我遇到的问题是,当我尝试清除适配器时,应用程序崩溃并抛出java.lang.UnsupportedOperationException
if(adapter != null) {
adapter.clear();
}
更新代码:
private void setListViewAdapterToDate(int month, int year, int dv)
{
if(summaryAdapter != null) {
summaryAdapter.clear();
}
setListView(month, year, dv);
summaryList.addAll(Arrays.asList(summary_data));
summaryAdapter = new SummaryAdapter(this.getActivity().getApplicationContext(), R.layout.listview_item_row, summaryList);
summaryAdapter.notifyDataSetChanged();
calendarSummary.setAdapter(summaryAdapter);
}