【发布时间】:2015-11-24 15:54:35
【问题描述】:
此代码在BlueStacks中有效,但是当智能手机运行时日志显示如下错误。
错误:
The content of the adapter has changed but ListView did not receive a
notification. Make sure the content of your adapter is not modified from a
background thread, but only from the UI thread. Make sure your adapter calls
notifyDataSetChanged() when its content changes. [in ListView(2131296334, class
android.widget.ListView) with Adapter(class android.widget.HeaderViewListAdapter)]
代码:
private void displayResultList() {
try {
array.clear();
array=baseHelper.results;
tView.setText("Size : " +array.size()+" "+ baseHelper.countmcur );
try {
if(arrayAdapter!=null)
arrayAdapter.notifyDataSetChanged();
arrayAdapter=new display();
listV.setAdapter(arrayAdapter);
arrayAdapter.notifyDataSetChanged();
} catch (Exception e) {
message.messages(contex, e.getMessage());
}
listV.setTextFilterEnabled(true);
} catch (Exception e) {
message.messages(contex, e.getMessage());
}
}
【问题讨论】:
-
你从哪里调用 displayResultList?如果这是一个异步任务,来自 doInBackground 还是来自 onPostExecute?
-
@Mdlc,button.setOnClickListener
标签: android arraylist android-listview dataadapter