dispatching input event
来源:互联网 发布:怎么看是淘宝客推广的 编辑:程序博客网 时间:2024/06/18 18:31
暑假在做Android的课程设计,大致上做完了,可是在用的时候,偶尔的就会“很抱歉,您的程序已停止运行”,那个部分大致是这样的:单击ListVIew clalist列表的一项,可跳转到详情界面,然后就在我退回listview界面再点击任意item的时候,问题就时不时地来了,由于不是每回都停止运行,我一直都不知道问题出在哪,查看log日志就是这么句话“dispatching input event”,“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.”意思是数据源变了,确实是,在退回listview 界面的时候,我刷新了一下界面,把填充数据list清空再加载,(我是在onResume()方法中写的这些)
list被清空后有一些耗时的操作,calist才重新绑定新的list,如果在这之前我点击item,list改变了但是在界面上,依旧显示原来的list,所以会报错啦,怎么改呢?So easy啦,修改mylist之后,在耗时操作之前,不要让原来的数据显示在listview上面了,只需要在
protected void onResume() { mylist.clear();BmobQuery<Acti> actis=new BmobQuery<Acti>();actis.addWhereEqualTo("classId", classid);actis.addWhereEqualTo("isexit", 1);actis.findObjects(ShowclassActivity.this, new FindListener<Acti>() {@Overridepublic void onSuccess(List<Acti> arg0) {actilist=arg0;for(int i=0;i<arg0.size();i++){Acti act=arg0.get(i);HashMap map=new HashMap();map.put("name", act.getName());map.put("num",i+1);mylist.add(map);}adapter=new SimpleAdapter(ShowclassActivity.this, mylist,R.layout.actilist, new String[]{"name","num"}, new int[]{R.id.actname,R.id.actnum});clalist.setAdapter(adapter);adapter.notifyDataSetChanged();}
list被清空后有一些耗时的操作,calist才重新绑定新的list,如果在这之前我点击item,list改变了但是在界面上,依旧显示原来的list,所以会报错啦,怎么改呢?So easy啦,修改mylist之后,在耗时操作之前,不要让原来的数据显示在listview上面了,只需要在
mylist.clear();
后面加一行代码:
clalist.setAdapter(null);
完美!
本来,一直找不着错误的我,打算抱着侥幸的心理,提交课设的,一直祈祷着演示的时候不要有这种错误,现在,
0 0
- Android Input Event Dispatching
- Android Input Event Dispatching
- Android Input Event Dispatching
- dispatching input event
- Exception dispatching input event. use XlistView
- The Event-Dispatching Thread
- Exception dispatching input event 缩放2个MpChart时发生终于搞定了
- android input event analyse
- Input event驱动
- input event types code
- Android Input Event Propagation
- adb shell input event
- Input Event 模块
- Input event 分析
- Androiod Input event
- Input Event Detect and Dispatch
- Input event驱动(ppt)
- Android input event架构分析
- java对redis的基本操作
- smooth函数
- clojure编程-延迟计算
- windows下编译ffmpeg
- (转)couchbase安装篇
- dispatching input event
- 简述Struts开发流程
- 脚本、appium、手机如何连在一起
- tomcat配置图片服务器,上传图片到服务器的硬盘上,而不是项目下
- POJ 3436 ACM Computer Factory(最大流)
- AngularJS自定义Echarts标签 — 柱状图Bar
- Java中的泛型方法
- Intent传递参数URI使用示例
- js个人笔记