{"id":707,"date":"2023-02-26T15:12:49","date_gmt":"2023-02-26T07:12:49","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=707"},"modified":"2023-02-26T15:12:49","modified_gmt":"2023-02-26T07:12:49","slug":"android-cannot-call-this-method-while-recyclerview-is-computing-a-layout-or-scrolling","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/02\/26\/android-cannot-call-this-method-while-recyclerview-is-computing-a-layout-or-scrolling\/","title":{"rendered":"Android Cannot call this method while RecyclerView is computing a layout or scrolling"},"content":{"rendered":"<p>\u5728\u4f7f\u7528RecyclerView\u65f6\u51fa\u73b0\u95ee\u9898\uff1a<\/p>\n<pre><code>java.lang.IllegalStateException: Cannot call this method while RecyclerView is computing a layout or scrolling<\/code><\/pre>\n<p><!-- more --><\/p>\n<p>\u51fa\u9519\u539f\u56e0\uff1a\u975e\u6cd5\u72b6\u6001\u5f02\u5e38\uff0c\u5373\u5f53RecyclerView\u5728\u8ba1\u7b97\u5e03\u5c40\uff0c\u6216\u8005\u5728\u6ed1\u52a8\u7684\u65f6\u5019\uff0c\u4e0d\u80fd\u8c03\u7528notifyDataSetChanged<\/p>\n<p>\u89e3\u51b3\u65b9\u6cd5\uff1a\u5728RecyclerView\u6ed1\u52a8\u6216\u8005\u8ba1\u7b97layout\u7684\u65f6\u5019\u4e0d\u5237\u65b0\u6570\u636e<\/p>\n<pre><code class=\"language-java\">if (mRecyclerView.getScrollState() == RecyclerView.SCROLL_STATE_IDLE &amp;&amp; (!mRecyclerView.isComputingLayout())) {\n    mAdapter.notifyDataSetChanged();\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u4f7f\u7528RecyclerView\u65f6\u51fa\u73b0\u95ee\u9898\uff1a java.lang.IllegalStateException:  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[119],"tags":[65],"class_list":["post-707","post","type-post","status-publish","format-standard","hentry","category-android-ui","tag-recyclerview"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/707","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=707"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/707\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=707"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=707"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=707"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}