更新列表视图的视图项而不通知DataSetChanged
我有一个带有列表视图的 Android 应用程序,其中 .. blablabla .. 呈现位置的标题和地址。此外,它还显示以米为单位的距离和指南针。
https://i.sstatic.net/k5XHF.jpg (抱歉还不能发布屏幕截图:)
每当我从 SensorManagers 侦听器获取新的罗盘数据时,我都会通知数据集更改,列表会使用新的轴承进行更新,一切都很好,但是它似乎将应用程序冻结了几毫秒,没什么严重的,但用户肯定会感觉到这种滞后 影响。
现在我真正的问题是:
是否可以仅更新“compasviews”而不执行notifyDataSetChanged? 我认为最好的方法是使用一些“findviewsbyid”函数,将目的地保存在 compasview 中,并且只更新 compasview,但我只能找到 findViewById 方法。
I have an android application with a listview which .. blablabla .. presents a title and adress of a location. Furthermore it displays a distance in meters and a compas.
https://i.sstatic.net/k5XHF.jpg (Sorry cant post screenshots yet :)
Whenever i get new compas data from my SensorManagers listener, i do notifyDataSetChanged the list is updated with the new bearing and everythings fine, however it seems to freeze the application for a few ms, nothing serious but the user can sure feel this laggy effect.
And now to my real question:
Is it possible to update only the "compasviews" without doing notifyDataSetChanged?
I thought the best way to go about this would be some "findviewsbyid"function, save the destination in the compasview it self and only update the compasview, but i can only find the findViewById method.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否在 UI 线程上进行大量计算?如果是这样,请考虑实现一个
AsyncTask
来计算新值,然后在的 onPostExecute()
方法中调用notifyDataSetChanged()
异步任务。Are you doing extensive calculations on the UI-thread? If so, consider implementing an
AsyncTask
for calculating the new values and then callnotifyDataSetChanged()
inonPostExecute()
-method of yourAsyncTask
.