【发布时间】:2014-02-22 02:19:02
【问题描述】:
我有一个数据包侦听器,可以检测数据包何时到达,并且在发生这种情况时我需要刷新ArrayAdapter。问题是如果我尝试访问adapter.notifyDataSetChanged() 方法,就会抛出异常:
Exception in packet listener: android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
有什么想法吗?
【问题讨论】:
-
你从哪里调用 adapter.notifyDataSetChanged() ?它必须来自另一个线程,而不是 UI 线程。
标签: android events android-arrayadapter notifydatasetchanged