简体   繁体   English

RecyclerView仅在屏幕关闭后更改

[英]RecyclerView only changes after the screen goes off

I first had a problem retrieving data from localhost then I added the code the 我首先遇到了从本地主机检索数据的问题,然后添加了代码

jsonArrayRequest.setRetryPolicy(new DefaultRetryPolicy(0, 0, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));

I no longer got an error. 我不再有错误。

However the data is only displayed once the screen goes off and I put is back on. 但是,只有在屏幕熄灭并且我重新打开后,才会显示数据。 Am I missing some line or code or should I remove some line of code? 我是否缺少某些行或代码,还是应该删除一些代码行?

So I found out the key was to update the recycler adapter to inform it that the data has changed. 因此,我发现关键是更新回收站适配器以通知它数据已更改。 With this line of code. 有了这一行代码。

adapter.notifyDataSetChanged();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM