【问题标题】:ListView exception - The content of the adapter has changed but ListView did not receive a notificationListView 异常 - 适配器的内容发生了变化,但 ListView 没有收到通知
【发布时间】:2014-04-26 18:29:05
【问题描述】:

我使用 listview 显示名为 numberlist 的 ArrayList 的内容,但有时会发生此异常 The content of the adapter has changed but ListView did not receive a notification 我使用 adapter.notifyDataSetChanged(); 但仍然遇到同样的问题,知道吗?

AsyncTask 的 onPostExecute:

adapter = new ListViewAdapter(getActivity(), numberlist);
listview.setAdapter(adapter);

【问题讨论】:

    标签: android android-listview


    【解决方案1】:

    您是否在更改 numberlist 时或在发布代码之前调用了 adapter.notifyDataSetChanged()?

    应该是每当 numberlist 发生变化时。

    【讨论】:

    • 我在上面几行之间调用了这个
    【解决方案2】:

    你能发布相关代码吗?听起来您可能正在某个地方从 UI 线程修改与您的适配器关联的列表。

    【讨论】:

      猜你喜欢
      • 2014-06-21
      • 1970-01-01
      • 2015-05-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-24
      • 1970-01-01
      相关资源
      最近更新 更多