在ListView中添加项目时,UI会冻结 [英] UI freezes while adding items inside the ListView

查看:65
本文介绍了在ListView中添加项目时,UI会冻结的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ListView来填充其中的项目。我有一个搜索框,用于向服务器发送请求,
获取数据。来自服务器的响应数据将添加到ListView。当我不断向服务器发送请求时,我会不断获取数据并更新ListView。这会在更新时导致UI冻结问题。因此,当我在搜索框中输入
时,UI会冻结,直到ListView更新完成。有人可以告诉我为什么会发生这种情况吗?

解决方案

我必须看到你的代码,但我怀疑搜索是在同步而不是异步

I am using ListView to populate items inside it. I have a search box which I use to send a request to the server and get the data. The response data from the server will be added to the ListView. When I continuously sends a request to the server, I keep getting the data and updates the ListView. This causes UI freezing problem while updating. So, when I type something inside the search box, UI freezes until the ListView update finishes. Can anybody please tell me why this is happening?

解决方案

I would have to see your code but I suspect that the search is taking place synchronously instead of async


这篇关于在ListView中添加项目时,UI会冻结的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆