{"id":351,"date":"2023-02-25T07:07:27","date_gmt":"2023-02-24T23:07:27","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=351"},"modified":"2023-04-30T14:46:17","modified_gmt":"2023-04-30T06:46:17","slug":"android-recyclerview-frequently-set-data-flashback-issues","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/02\/25\/android-recyclerview-frequently-set-data-flashback-issues\/","title":{"rendered":"Android RecyclerView\u9891\u7e41\u8bbe\u7f6e\u6570\u636e\u95ea\u9000\u95ee\u9898"},"content":{"rendered":"<p>\u6d4b\u8bd5RecyclerView\u9891\u7e41\u5237\u65b0\u6570\u636e\u65f6\uff0c\u62a5\u51fa\u4ee5\u4e0b\u9519\u8bef\uff1a<\/p>\n<pre><code>java.lang.IllegalArgumentException\nScrapped or attached views may not be recycled. isScrap:false isAttached:true<\/code><\/pre>\n<p><!-- more --><\/p>\n<p>\u662f\u6307view\u6ca1\u6709\u88abrecycled\uff0c\u539f\u56e0\u662fRecyclerView\u7684\u6570\u636e\u8fdb\u884c\u6e05\u7a7a\u64cd\u4f5c\u4e4b\u540e\uff0c\u5728\u91cd\u65b0\u6dfb\u52a0\u6570\u636e\u4e4b\u524d\u6ca1\u6709\u901a\u77e5\u754c\u9762\u8fdb\u884c\u91cd\u65b0\u7ed8\u5236\uff0c\u6240\u4ee5\u5d29\u6e83\u3002 <\/p>\n<p>\u89e3\u51b3\u65b9\u6cd5\u53ea\u8981\u5728clear()\u6570\u636e\u4e4b\u540eaddAll(list)\u4e4b\u524d\u7684\u4ee3\u7801\u4e2d\u52a0\u4e0anotifyDataSetChanged()\u5373\u53ef\u3002<\/p>\n<pre><code>public void loadDocumentList(boolean increment) {\n    if (!increment) {\n        mToVerifyDocumentVerifyList.clear();\n        mToVerifyFragment.notifyDataSetChanged();\n    }\n    mPresenter.loadDocumentList(mDocumentList, increment);\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u6d4b\u8bd5RecyclerView\u9891\u7e41\u5237\u65b0\u6570\u636e\u65f6\uff0c\u62a5\u51fa\u4ee5\u4e0b\u9519\u8bef\uff1a java.lang.IllegalArgument [&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-351","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\/351","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=351"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/351\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=351"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=351"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=351"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}