我现在做的是一个树形菜单,就和书的目录差不多,效果出来了,就是中间处理事件时出了点问题:我点定义了一个list,用来存放一级目录:
private List<Map<String,String>> list = new ArrayList<Map<String,String>>();然后又定义了一个ChildList,用来存放二级目录:
private List<List<Map<String, String>>> childList = new ArrayList<List<Map<String, String>>>();在数据库中查询的目录分别放在list、childList中,然后通过
mAdapter = new SimpleExpandableListAdapter(this,list,R.layout.list_mulu,from,to,childList,R.layout.list_mulu,from,to);
expandableList.setAdapter(mAdapter);
加载到ExpandableListView中。问题是,还有三级目录,当我点击二级目录,触发事件时,将三级目录的内容显示出来,当三级目录显示出来后,我再点二级目录重新获取三级目录时就报错了:
“The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not nodified from a background thread.but only from the UI thread”我用adapter.getCount()取值测了一下,可能还有线程在跑,更新了mAdapter.getCount();的返回值
但不知道如何处理一下,希望大家多多指教!
private List<Map<String,String>> list = new ArrayList<Map<String,String>>();然后又定义了一个ChildList,用来存放二级目录:
private List<List<Map<String, String>>> childList = new ArrayList<List<Map<String, String>>>();在数据库中查询的目录分别放在list、childList中,然后通过
mAdapter = new SimpleExpandableListAdapter(this,list,R.layout.list_mulu,from,to,childList,R.layout.list_mulu,from,to);
expandableList.setAdapter(mAdapter);
加载到ExpandableListView中。问题是,还有三级目录,当我点击二级目录,触发事件时,将三级目录的内容显示出来,当三级目录显示出来后,我再点二级目录重新获取三级目录时就报错了:
“The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not nodified from a background thread.but only from the UI thread”我用adapter.getCount()取值测了一下,可能还有线程在跑,更新了mAdapter.getCount();的返回值
但不知道如何处理一下,希望大家多多指教!
true就不做处理?
再点二级目录应该是关闭二级目录才对啊,是不是我理解错了?
二级目录不需要刷新,应该不用关闭我这样处理的,当再点二级菜单时应该将三级目录刷新,所以先将三级目录隐藏:
listView.setVisibility(View.GONE);当取值完毕后再将三级目录显示出来,但还是那个错误。总觉得是adapter的问题...
估计错误出在那个getview下面
我感觉
http://my.csdn.net/my/album/detail/1175768