绑定ListView的时候弹出这样的错误,有时正常有时会出现这样的错误

Alfredknox 2013-09-27 11:56:04
09-27 03:52:16.288: W/dalvikvm(1160): threadid=29: thread exiting with uncaught exception (group=0x40a13300)
09-27 03:52:16.357: E/AndroidRuntime(1160): FATAL EXCEPTION: 504146fc-6846-4a16-ba2d-75e6980bc462
09-27 03:52:16.357: E/AndroidRuntime(1160): android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
09-27 03:52:16.357: E/AndroidRuntime(1160): at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:4609)
09-27 03:52:16.357: E/AndroidRuntime(1160): at android.view.ViewRootImpl.focusableViewAvailable(ViewRootImpl.java:2576)
09-27 03:52:16.357: E/AndroidRuntime(1160): at android.view.ViewGroup.focusableViewAvailable(ViewGroup.java:604)
09-27 03:52:16.357: E/AndroidRuntime(1160): at android.view.ViewGroup.focusableViewAvailable(ViewGroup.java:604)
09-27 03:52:16.357: E/AndroidRuntime(1160): at android.view.ViewGroup.focusableViewAvailable(ViewGroup.java:604)
09-27 03:52:16.357: E/AndroidRuntime(1160): at android.view.ViewGroup.focusableViewAvailable(ViewGroup.java:604)
09-27 03:52:16.357: E/AndroidRuntime(1160): at android.view.ViewGroup.focusableViewAvailable(ViewGroup.java:604)
09-27 03:52:16.357: E/AndroidRuntime(1160): at android.view.ViewGroup.focusableViewAvailable(ViewGroup.java:604)
09-27 03:52:16.357: E/AndroidRuntime(1160): at android.view.View.setFlags(View.java:8290)
09-27 03:52:16.357: E/AndroidRuntime(1160): at android.view.View.setFocusableInTouchMode(View.java:5586)
09-27 03:52:16.357: E/AndroidRuntime(1160): at android.widget.AdapterView.checkFocus(AdapterView.java:717)
09-27 03:52:16.357: E/AndroidRuntime(1160): at android.widget.ListView.setAdapter(ListView.java:461)
09-27 03:52:16.357: E/AndroidRuntime(1160): at org.buildingknox.com.WorkOrderList$MyHandler.handleMessage(WorkOrderList.java:137)
09-27 03:52:16.357: E/AndroidRuntime(1160): at android.os.Handler.dispatchMessage(Handler.java:99)
09-27 03:52:16.357: E/AndroidRuntime(1160): at android.os.Looper.loop(Looper.java:137)
09-27 03:52:16.357: E/AndroidRuntime(1160): at android.os.HandlerThread.run(HandlerThread.java:60)
...全文
88 点赞 收藏 6
写回复
6 条回复
Alfredknox 2013年09月27日
引用 3 楼 tantahe 的回复:
看log是不能在子线程更新UI。你可以用handler来更新。
这样说吧,连续操作大概10次会出错一次,不知道哪里出错了!
回复 点赞
tantahe 2013年09月27日
看log是不能在子线程更新UI。你可以用handler来更新。
回复 点赞
Alfredknox 2013年09月27日
else if (b.getInt(ConfigDataFieldHelper.BundleDataFields.DATARESULTFIELD) == ConfigDataFieldHelper.BundleDataResult.DataSuccessfully) { lstMaps = (List<Map<String, Object>>) b .get(ConfigDataFieldHelper.BundleDataFields.DATA); adapter = new SimpleAdapter(WorkOrderList.this, lstMaps, R.layout.work_order_list_items, new String[] { "OrderId", "Unit", "Type", "OrderDate", "Description" }, new int[] { R.id.work_order_list_item_orderid, R.id.work_order_list_item_unit, R.id.work_order_list_item_type, R.id.work_order_list_item_date, R.id.work_order_list_item_description }); lstWorkOrder.setAdapter(adapter); lstWorkOrder.setOnItemClickListener(lstOrderItem); } 如果出话,总是会在红色这里出错
回复 点赞
Alfredknox 2013年09月27日
if (b.getInt(ConfigDataFieldHelper.BundleDataFields.DATARESULTFIELD) == ConfigDataFieldHelper.BundleDataResult.DataEmpty)
					{
						List<Map<String, Object>> lstMapsNull = (List<Map<String, Object>>) b
								.get(ConfigDataFieldHelper.BundleDataFields.DATA);
						SimpleAdapter adapterNull = new SimpleAdapter(
								WorkOrderList.this, lstMapsNull,
								android.R.layout.simple_list_item_1,
								new String[]
								{
									"Msg"
								}, new int[]
								{
									android.R.id.text1
								});
						lstWorkOrder.setAdapter(adapterNull);
					}
回复 点赞
Alfredknox 2013年09月27日
09-27 06:52:46.738: E/OrderId(1545): 3
09-27 06:52:46.738: E/Unit(1545): S1
09-27 06:52:46.738: E/Type(1545): Hardware
09-27 06:52:46.738: E/OrderDate(1545): 09/18/2012
09-27 06:52:46.738: E/Description(1545): OOOOOOOO000 test Android To Alfred
上面的结果是正确的,而不明白为什么还会出现下面的绑定错误

09-27 06:52:46.738: W/dalvikvm(1545): threadid=22: thread exiting with uncaught exception (group=0x40a13300)
09-27 06:52:46.807: E/AndroidRuntime(1545): FATAL EXCEPTION: 821d7831-2724-40b0-88b2-cb2c935cb214
09-27 06:52:46.807: E/AndroidRuntime(1545): android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
09-27 06:52:46.807: E/AndroidRuntime(1545): 	at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:4609)
09-27 06:52:46.807: E/AndroidRuntime(1545): 	at android.view.ViewRootImpl.focusableViewAvailable(ViewRootImpl.java:2576)
09-27 06:52:46.807: E/AndroidRuntime(1545): 	at android.view.ViewGroup.focusableViewAvailable(ViewGroup.java:604)
09-27 06:52:46.807: E/AndroidRuntime(1545): 	at android.view.ViewGroup.focusableViewAvailable(ViewGroup.java:604)
09-27 06:52:46.807: E/AndroidRuntime(1545): 	at android.view.ViewGroup.focusableViewAvailable(ViewGroup.java:604)
09-27 06:52:46.807: E/AndroidRuntime(1545): 	at android.view.ViewGroup.focusableViewAvailable(ViewGroup.java:604)
09-27 06:52:46.807: E/AndroidRuntime(1545): 	at android.view.ViewGroup.focusableViewAvailable(ViewGroup.java:604)
09-27 06:52:46.807: E/AndroidRuntime(1545): 	at android.view.ViewGroup.focusableViewAvailable(ViewGroup.java:604)
09-27 06:52:46.807: E/AndroidRuntime(1545): 	at android.view.View.setFlags(View.java:8290)
09-27 06:52:46.807: E/AndroidRuntime(1545): 	at android.view.View.setFocusableInTouchMode(View.java:5586)
09-27 06:52:46.807: E/AndroidRuntime(1545): 	at android.widget.AdapterView.checkFocus(AdapterView.java:717)
09-27 06:52:46.807: E/AndroidRuntime(1545): 	at android.widget.ListView.setAdapter(ListView.java:461)
09-27 06:52:46.807: E/AndroidRuntime(1545): 	at org.buildingknox.com.WorkOrderList$MyHandler.handleMessage(WorkOrderList.java:150)
09-27 06:52:46.807: E/AndroidRuntime(1545): 	at android.os.Handler.dispatchMessage(Handler.java:99)
09-27 06:52:46.807: E/AndroidRuntime(1545): 	at android.os.Looper.loop(Looper.java:137)
09-27 06:52:46.807: E/AndroidRuntime(1545): 	at android.os.HandlerThread.run(HandlerThread.java:60)
09-27 06:52:47.447: I/Choreographer(1545): Skipped 82 frames!  The application may be doing too much work on its main thread.
09-27 06:52:47.638: D/AndroidRuntime(1545): Shutting down VM
09-27 06:52:47.638: W/dalvikvm(1545): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
09-27 06:52:47.678: I/Process(1545): Sending signal. PID: 1545 SIG: 9
回复 点赞
发动态
发帖子
Android
创建于2009-10-09

4.6w+

社区成员

9.0w+

社区内容

移动平台 Android
社区公告
暂无公告