{"id":1189,"date":"2016-02-04T20:05:40","date_gmt":"2016-02-04T12:05:40","guid":{"rendered":"https:\/\/ai.zhousir.top\/?p=1189"},"modified":"2016-02-04T21:07:58","modified_gmt":"2016-02-04T13:07:59","slug":"recyclerview%e5%88%9d%e6%8e%a2","status":"publish","type":"post","link":"https:\/\/ai.zhousir.top\/?p=1189","title":{"rendered":"RecyclerView\u521d\u63a2"},"content":{"rendered":"<p>\u8fd9\u5e94\u8be5\u662f\u521d\u6b65\u4e86\u89e3RecyclerView\u5168\u8c8c\u7684\u6700\u4f73\u6587\u7ae0\u3002<\/p>\n<p>RecyclerView\u662f\u53bb\u5e74\u8c37\u6b4cI\/O\u5927\u4f1a\u4e0a\u968fAndroid L\u9884\u89c8\u4e00\u8d77\u53d1\u5e03\u7684\uff0c\u63a5\u4e0b\u6765\u7684\u51e0\u7bc7\u8bd1\u6587\u5c06\u4f1a\u4ece\u5404\u4e2a\u65b9\u9762\u5bf9RecyclerView\u505a\u4e00\u4e2a\u5168\u9762\u7684\u4ecb\u7ecd\uff1a<!--more--><\/p>\n<h2 id=\"\u4e3a\u4ec0\u4e48\u53ebrecyclerview\"><a name=\"t0\"><\/a>\u4e3a\u4ec0\u4e48\u53ebRecyclerView\uff1f<\/h2>\n<p>\u8c37\u6b4c\u5728Android L\u9884\u89c8\u7248API\u6587\u6863\u4e2d\u662f\u8fd9\u6837\u63cf\u8ff0\u7684\uff1a<br \/>\n<strong>\u4e00\u4e2a\u975e\u5e38\u7075\u6d3b\u7684\u7528\u4e8e\u5728\u6709\u9650\u7684\u7a97\u53e3\u8303\u56f4\u5185\u663e\u793a\u5927\u91cf\u6570\u636e\u7684\u63a7\u4ef6\u3002<\/strong><br \/>\n\u6240\u4ee5RecyclerView\u9002\u7528\u4e8e\u90a3\u4e9b\u6709\u5927\u91cf\u540c\u7c7b\u7684View\u4f46\u662f\u4e0d\u80fd\u540c\u65f6\u5728\u5c4f\u5e55\u4e2d\u663e\u793a\u7684\u60c5\u51b5\uff0c\u6bd4\u5982\u8054\u7cfb\u4eba\u3001\u7528\u6237\u5217\u8868\u3001\u97f3\u4e50\u6587\u4ef6\u5217\u8868\u7b49\u7b49\u3002\u60f3\u770b\u5230\u66f4\u591a\u4fe1\u606f\u9700\u8981\u6eda\u52a8\u8bd5\u56fe\uff0c\u540c\u65f6\u5bf9\u79bb\u5f00\u5c4f\u5e55\u7684\u89c6\u56fe\u8fdb\u884c<strong>\u56de\u6536\u548c\u91cd\u7528<\/strong>\u3002<\/p>\n<p>\u4ee5\u4e0b\u56fe\u7247\u89e3\u91ca\u4e86\u8fd9\u4e2a\u8fc7\u7a0b\uff1a\u5de6\u8fb9\u662f\u5e94\u7528\u7a0b\u5e8f\u7684\u521d\u59cb\u72b6\u6001\uff0c\u5f53\u5411\u4e0a\u6eda\u52a8\u89c6\u56fe\u7684\u65f6\u5019\uff0c\u4e00\u4e9b\u5b50View\u51c6\u5907\u88ab\u56de\u6536\uff0c\u6bd4\u5982\u53f3\u8fb9\u7684\u7ea2\u6846\u90e8\u5206\u4e2d\u7684\u4e24\u4e2a\u4e0d\u53ef\u89c1\u7684View\u3002\u73b0\u5728\u56de\u6536\u5668\u53ef\u4ee5\u628a\u4ed6\u4eec\u653e\u5165\u51c6\u5907\u91cd\u7528\u7684View\u7684\u5217\u8868\u4ee5\u4fbf\u5728\u9002\u5f53\u7684\u65f6\u5019\u91cd\u7528\u3002<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"\" title=\"\" src=\"http:\/\/www.grokkingandroid.com\/wordpress\/wp-content\/uploads\/2014\/08\/recycling_of_views-300x227.png\" alt=\"\u8fd9\u91cc\u5199\u56fe\u7247\u63cf\u8ff0\" width=\"367\" height=\"278\" \/><\/p>\n<p>\u5bf9View\u7684\u56de\u6536\u91cd\u7528\u662f\u975e\u5e38\u6709\u7528\u7684\uff0c\u7531\u4e8e\u4e0d\u7528\u6bcf\u6b21\u90fd\u91cd\u65b0\u586b\u5145\u5e03\u5c40\uff0c\u8fd9\u6837\u53ef\u4ee5\u8282\u7ea6CPU\u8d44\u6e90\uff1b\u540c\u65f6\u7531\u4e8e\u4e0d\u7528\u4fdd\u5b58\u5927\u91cf\u7684\u4e0d\u53ef\u89c1\u7684\u89c6\u56fe\uff0c\u4e5f\u6709\u6548\u7684\u8282\u7701\u4e86\u5185\u5b58\u8d44\u6e90\u3002<\/p>\n<p>\u770b\u5230\u8fd9\u91cc\u53ef\u80fd\u6709\u4eba\u8981\u8bf4\uff0c\u8fd9\u4e2a\u6982\u5ff5\u65e9\u5c31\u6709\u4e86\uff0cListView\u5c31\u662f\u4f7f\u7528\u8fd9\u6837\u7684\u673a\u5236\u3002\u662f\u7684\u6ca1\u9519\uff0c\u4f46\u662f\u5728ListView\u4e2d\uff0c\u63a7\u4ef6\u5916\u89c2\u3001\u56de\u6536\u8fc7\u7a0b\u548c\u5176\u4ed6\u64cd\u4f5c\u662f\u7d27\u8026\u5408\u7684\uff0c\u7f3a\u4e4f\u7075\u6d3b\u6027\uff0c\u8fd9\u5c31\u662f\u4e3a\u4ec0\u4e48\u8c37\u6b4c\u8981\u5f00\u53d1RecyclerView\u6765\u53d6\u4ee3\u5b83\u7684\u610f\u4e49\u6240\u5728\u3002<\/p>\n<h2 id=\"recyclerview\u672c\u8eab\u4e0d\u5173\u5fc3\u89c6\u56fe\u76f8\u5173\u7684\u95ee\u9898\"><a name=\"t1\"><\/a>RecyclerView\u672c\u8eab\u4e0d\u5173\u5fc3\u89c6\u56fe\u76f8\u5173\u7684\u95ee\u9898<\/h2>\n<p>\u7531\u4e8eListView\u7684\u7d27\u8026\u5408\u95ee\u9898\uff0c\u8c37\u6b4c\u7684\u6539\u8fdb\u5c31\u662fRecyclerView\u672c\u8eab\u4e0d\u53c2\u4e0e\u4efb\u4f55\u89c6\u56fe\u76f8\u5173\u7684\u95ee\u9898\u3002\u5b83\u4e0d\u5173\u5fc3\u5982\u4f55\u5c06\u5b50View\u653e\u5728\u5408\u9002\u7684\u4f4d\u7f6e\uff0c\u4e5f\u4e0d\u5173\u5fc3\u5982\u4f55\u5206\u5272\u8fd9\u4e9b\u5b50View\uff0c\u66f4\u4e0d\u5173\u5fc3\u6bcf\u4e2a\u5b50View\u5404\u81ea\u7684\u5916\u89c2\u3002\u8fdb\u4e00\u6b65\u6765\u8bf4\uff0cRecyclerView\u53ea\u8d1f\u8d23\u56de\u6536\u548c\u91cd\u7528\u7684\u5de5\u4f5c\uff0c\u8fd9\u5c31\u662f\u5b83\u540d\u5b57\u7684\u7531\u6765\u3002<\/p>\n<p>\u6240\u6709\u5173\u4e8e\u5e03\u5c40\u3001\u7ed8\u5236\u548c\u5176\u4ed6\u76f8\u5173\u7684\u95ee\u9898\uff0c\u4e5f\u5c31\u662f<strong>\u8ddf\u6570\u636e\u5c55\u793a\u76f8\u5173\u7684\u6240\u6709\u95ee\u9898\uff0c\u90fd\u88ab\u59d4\u6d3e\u7ed9\u4e86\u4e00\u4e9b\u201d\u63d2\u4ef6\u5316\u201d\u7684\u7c7b\u6765\u5904\u7406\u3002<\/strong>\u8fd9\u4f7f\u5f97RecyclerView\u7684API\u53d8\u5f97\u975e\u5e38\u7075\u6d3b\u3002\u4f60\u9700\u8981\u4e00\u4e2a\u65b0\u7684\u5e03\u5c40\u4e48\uff1f\u63a5\u5165\u53e6\u4e00\u4e2aLayoutManager\u5c31\u53ef\u4ee5\u4e86\uff01\u4f60\u60f3\u8981\u4e0d\u540c\u7684\u52a8\u753b\u4e48\uff1f\u63a5\u5165\u4e00\u4e2a\u65b0\u7684ItemAnimator\u5c31\u53ef\u4ee5\u4e86\uff0c\u8bf8\u5982\u6b64\u7c7b\u3002<\/p>\n<p>\u4ee5\u4e0b\u662fRecyclerView\u4e2d\u7528\u4e8e\u6570\u636e\u5c55\u793a\u7684\u4e00\u4e9b\u91cd\u8981\u7684\u7c7b\uff0c\u4ed6\u4eec\u90fd\u662fRecyclerView\u7684\u5185\u90e8\u7c7b\uff1a<\/p>\n<ul>\n<li>Adapter\uff1a\u5305\u88c5\u6570\u636e\u96c6\u5408\u5e76\u4e14\u4e3a\u6bcf\u4e2a\u6761\u76ee\u521b\u5efa\u89c6\u56fe\u3002<\/li>\n<li>ViewHolder\uff1a\u4fdd\u5b58\u7528\u4e8e\u663e\u793a\u6bcf\u4e2a\u6570\u636e\u6761\u76ee\u7684\u5b50View\u3002<\/li>\n<li>LayoutManager\uff1a\u5c06\u6bcf\u4e2a\u6761\u76ee\u7684\u89c6\u56fe\u653e\u7f6e\u4e8e\u9002\u5f53\u7684\u4f4d\u7f6e\u3002<\/li>\n<li>ItemDecoration\uff1a\u5728\u6bcf\u4e2a\u6761\u76ee\u7684\u89c6\u56fe\u7684\u5468\u56f4\u6216\u4e0a\u9762\u7ed8\u5236\u4e00\u4e9b\u88c5\u9970\u89c6\u56fe\u3002<\/li>\n<li>ItemAnimator\uff1a\u5728\u6761\u76ee\u88ab\u6dfb\u52a0\u3001\u79fb\u9664\u6216\u8005\u91cd\u6392\u5e8f\u65f6\u6dfb\u52a0\u52a8\u753b\u6548\u679c\u3002<\/li>\n<\/ul>\n<p>\u4e0b\u9762\u5c06\u5bf9\u8fd9\u4e9b\u7c7b\u8fdb\u884c\u5206\u522b\u4ecb\u7ecd\uff1a<\/p>\n<h2 id=\"recyclerviewviewholder\"><a name=\"t2\"><\/a>RecyclerView.ViewHolder<\/h2>\n<p>ViewHolder\u7684\u57fa\u672c\u4f5c\u7528\u662f\u7f13\u5b58\u89c6\u56fe\u5bf9\u8c61\uff0cAndroid\u5b98\u65b9\u5f88\u65e9\u94b1\u5c31\u63a8\u8350\u4f7f\u7528ViewHolder\u7684\u7f16\u7a0b\u6a21\u5f0f\uff0c\u4f46\u662f\u73b0\u5728\u4f7f\u7528\u8fd9\u79cd\u6a21\u5f0f\u5c06\u662f\u5f3a\u5236\u6027\u7684\u3002<\/p>\n<p>RecyclerView.ViewHolder\u7684\u5b50\u7c7b\u90fd\u53ef\u4ee5\u901a\u8fc7ViewHolder\u7684public\u7684\u6210\u5458\u53d8\u91cfitemView\u6765\u8bbf\u95ee\u6bcf\u4e2a\u6761\u76ee\u7684\u6839\u89c6\u56fe\uff0c\u6240\u4ee5ViewHolder\u5b50\u7c7b\u4e2d\u4e0d\u9700\u8981\u5728\u4fdd\u5b58\u8fd9\u4e2a\u89c6\u56fe\u3002<\/p>\n<p>\u4ee5\u4e0b\u662fViewHolder\u7684\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n<pre class=\"prettyprint\"><code class=\"hljs java has-numbering\"><span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">final<\/span> <span class=\"hljs-keyword\">static<\/span> <span class=\"hljs-class\"><span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-title\">ListItemViewHolder<\/span> <span class=\"hljs-keyword\">extends<\/span> <span class=\"hljs-title\">RecyclerView<\/span>.<span class=\"hljs-title\">ViewHolder<\/span> {<\/span>\r\n   TextView label;\r\n   TextView dateTime;\r\n\r\n   <span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-title\">ListItemViewHolder<\/span>(View itemView) {\r\n      <span class=\"hljs-keyword\">super<\/span>(itemView);\r\n      label = (TextView)itemView.findViewById(R.id.txt_label_item);\r\n      dateTime = (TextView)itemView.findViewById(R.id.txt_date_time);\r\n   }\r\n}<\/code><\/pre>\n<h2 id=\"recyclerviewadapter\"><a name=\"t3\"><\/a>RecyclerView.Adapter<\/h2>\n<p>Adapter\u5145\u5f53\u4e24\u4e2a\u89d2\u8272\uff1a\u8bbf\u95ee\u6570\u636e\u96c6\u5408\u4ee5\u53ca\u8d1f\u8d23\u4e3a\u6bcf\u4e2a\u6761\u76ee\u521b\u5efa\u6b63\u786e\u7684\u89c6\u56fe\u3002Adapter\u5728Android\u4e2d\u7ecf\u5e38\u51fa\u73b0\uff0c\u6bd4\u5982ListView\u3001AutoCompleteTextView\u3001Spinner\u7b49\uff0c\u4ed6\u4eec\u90fd\u7ee7\u627f\u81eaAdapterView\uff0c\u4f46\u662fRecyclerView\u5e76\u6ca1\u6709\u8fd9\u6837\u505a\u3002<\/p>\n<p>\u5bf9\u4e8eRecyclerView\uff0c\u8c37\u6b4c\u51b3\u5b9a\u4f7f\u7528\u65b0\u7684RecyclerView.Adapter\u57fa\u7c7b\u6765\u53d6\u4ee3\u65e7\u7684Adapter\u63a5\u53e3\u3002\u6240\u4ee5\uff0cSimpleCursorAdapter\u3001ArrayAdapter\u90fd\u5c06\u6210\u4e3a\u5386\u53f2\uff0c\u6216\u8005\u81f3\u5c11\u4e0d\u4f1a\u662f\u4ed6\u4eec\u73b0\u5728\u7684\u8fd9\u79cd\u4f7f\u7528\u65b9\u5f0f\u3002<\/p>\n<p>\u76ee\u524dRecyclerView.Adapter\u8fd8\u6ca1\u6709\u9ed8\u8ba4\u5b9e\u73b0\uff0c\u4ee5\u540e\u53ef\u80fd\u4f1a\u6dfb\u52a0\u3002\u7531\u4e8eRecyclerView.Adapter\u662f\u4e00\u4e2a\u62bd\u8c61\u7c7b\uff0c\u6240\u4ee5\u5fc5\u987b\u8981\u5b9e\u73b0\u4ee5\u4e0b\u4e09\u4e2a\u65b9\u6cd5\uff1a<\/p>\n<ul>\n<li>public VH onCreateViewHolder(ViewGroup parent, int viewType)<\/li>\n<li>public void onBindViewHolder(VH holder, int position)<\/li>\n<li>public int getItemCount()<\/li>\n<\/ul>\n<p>\u5176\u4e2dVH\u662f\u6cdb\u578b\u7c7b\uff0c\u5f53\u7ee7\u627fRecyclerView.Adapter\u65f6\u9700\u8981\u4f7f\u7528\u5177\u4f53\u7684\u7c7b\u6765\u66ff\u6362\u3002Adapter\u7684\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre class=\"prettyprint\"><code class=\"hljs axapta has-numbering\"><span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-class\"><span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-title\">RecyclerViewDemoAdapter<\/span> <span class=\"hljs-inheritance\"><span class=\"hljs-keyword\">extends<\/span><\/span> <span class=\"hljs-title\">RecyclerView<\/span>.<span class=\"hljs-title\">Adapter<\/span> &lt;<span class=\"hljs-title\">RecyclerViewDemoAdapter<\/span>.<span class=\"hljs-title\">ListItemViewHolder<\/span>&gt; {<\/span>\r\n\r\n    <span class=\"hljs-keyword\">private<\/span> List&lt;DemoModel&gt; items;\r\n\r\n    RecyclerViewDemoAdapter(List&lt;DemoModel&gt; modelData) {\r\n        <span class=\"hljs-keyword\">if<\/span> (modelData == <span class=\"hljs-keyword\">null<\/span>) {\r\n            <span class=\"hljs-keyword\">throw<\/span> <span class=\"hljs-keyword\">new<\/span> IllegalArgumentException(\r\n                  <span class=\"hljs-string\">\"modelData must not be null\"<\/span>);\r\n        }\r\n        <span class=\"hljs-keyword\">this<\/span>.items = modelData;\r\n    }\r\n\r\n    @Override\r\n    <span class=\"hljs-keyword\">public<\/span> ListItemViewHolder onCreateViewHolder(ViewGroup viewGroup, <span class=\"hljs-keyword\">int<\/span> viewType) {\r\n        View itemView = LayoutInflater.\r\n                from(viewGroup.getContext()).\r\n                inflate(R.layout.item_demo_01, \r\n                        viewGroup,\r\n                        <span class=\"hljs-keyword\">false<\/span>);\r\n        <span class=\"hljs-keyword\">return<\/span> <span class=\"hljs-keyword\">new<\/span> ListItemViewHolder(itemView);\r\n    }\r\n\r\n    @Override\r\n    <span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">void<\/span> onBindViewHolder(ListItemViewHolder viewHolder, <span class=\"hljs-keyword\">int<\/span> position) {\r\n        DemoModel model = items.get(position);\r\n        viewHolder.label.setText(model.label);\r\n        String dateStr = DateUtils.formatDateTime(\r\n                viewHolder.label.getContext(),\r\n                model.dateTime.getTime(),\r\n                DateUtils.FORMAT_ABBREV_ALL);\r\n        viewHolder.dateTime.setText(dateStr);\r\n    }\r\n\r\n    @Override\r\n    <span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">int<\/span> getItemCount() {\r\n        <span class=\"hljs-keyword\">return<\/span> items.size();\r\n    }\r\n\r\n    <span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">final<\/span> <span class=\"hljs-keyword\">static<\/span> <span class=\"hljs-class\"><span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-title\">ListItemViewHolder<\/span> \r\n           <span class=\"hljs-inheritance\"><span class=\"hljs-keyword\">extends<\/span><\/span> <span class=\"hljs-title\">RecyclerView<\/span>.<span class=\"hljs-title\">ViewHolder<\/span> {<\/span>\r\n        <span class=\"hljs-comment\">\/\/ ... shown above in the ViewHolder section<\/span>\r\n    }\r\n}<\/code><\/pre>\n<h2 id=\"recyclerviewlayoutmanager\"><a name=\"t4\"><\/a>RecyclerView.LayoutManager<\/h2>\n<p>LayoutManager\u53ef\u80fd\u662fRecyclerView\u4e2d\u6700\u6709\u8da3\u7684\u90e8\u5206\u4e86\uff0c\u8be5\u7c7b\u8d1f\u8d23\u653e\u7f6e\u6240\u6709\u7684\u5b50View\u5230\u9002\u5f53\u4f4d\u7f6e\u3002\u8be5\u7c7b\u6709\u4e00\u4e2a\u9ed8\u8ba4\u7684\u5b9e\u73b0\uff1aLinearLayoutManager\uff0c\u5f53\u8981\u5b9e\u73b0\u6c34\u5e73\u6216\u5782\u76f4\u5217\u8868\u65f6\u53ef\u4ee5\u4f7f\u7528\u8be5\u7c7b\u3002<\/p>\n<p>\u5fc5\u987b\u8981\u7ed9RecyclerView\u8bbe\u7f6e\u4e00\u4e2aLayoutManager\uff0c\u5426\u5219\u4f1a\u629b\u51fa\u5f02\u5e38\uff1a<\/p>\n<pre class=\"prettyprint\"><code class=\"hljs oxygene has-numbering\"><span class=\"hljs-number\">08<\/span>-<span class=\"hljs-number\">01<\/span> <span class=\"hljs-number\">05<\/span>:<span class=\"hljs-number\">00<\/span>:<span class=\"hljs-number\">00.000<\/span>  <span class=\"hljs-number\">2453<\/span>  <span class=\"hljs-number\">2453<\/span> E AndroidRuntime: java.lang.NullPointerException: Attempt <span class=\"hljs-keyword\">to<\/span> invoke <span class=\"hljs-keyword\">virtual<\/span> <span class=\"hljs-function\"><span class=\"hljs-keyword\">method<\/span> '<span class=\"hljs-title\">void<\/span> <span class=\"hljs-title\">android<\/span>.<span class=\"hljs-title\">support<\/span>.<span class=\"hljs-title\">v7<\/span>.<span class=\"hljs-title\">widget<\/span>.<span class=\"hljs-title\">RecyclerView<\/span>$<span class=\"hljs-title\">LayoutManager<\/span>.<span class=\"hljs-title\">onMeasure<\/span><span class=\"hljs-params\">(android.support.v7.widget.RecyclerView$Recycler, android.support.v7.widget.RecyclerView$State, int, int)<\/span>' <span class=\"hljs-title\">on<\/span> <span class=\"hljs-title\">a<\/span> <span class=\"hljs-title\">null<\/span> <span class=\"hljs-title\">object<\/span> <span class=\"hljs-title\">reference<\/span>\r\n08-01 05:<\/span><span class=\"hljs-number\">00<\/span>:<span class=\"hljs-number\">00.000<\/span>  <span class=\"hljs-number\">2453<\/span>  <span class=\"hljs-number\">2453<\/span> E AndroidRuntime:    at android.support.v7.widget.RecyclerView.onMeasure(RecyclerView.java:<span class=\"hljs-number\">1310<\/span>)<\/code><\/pre>\n<p>\u76ee\u524dLayoutManager\u53ea\u6709\u4e00\u4e2a\u62bd\u8c61\u65b9\u6cd5\uff1a<\/p>\n<ul>\n<li>public LayoutParams generateDefaultLayoutParams()\u4f46\u662f\u8fd8\u6709\u4e00\u4e2a\u65b9\u6cd5\u9700\u8981\u91cd\u5199\uff0c\u56e0\u4e3a\u8fd9\u4e2a\u65b9\u6cd5\u5f88\u5feb\u5c31\u8981\u53d8\u6210\u62bd\u8c61\u7684\u4e86\uff1a<\/li>\n<\/ul>\n<pre class=\"prettyprint\"><code class=\"hljs cs has-numbering\"><span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">void<\/span> <span class=\"hljs-title\">scrollToPosition<\/span>(<span class=\"hljs-keyword\">int<\/span> position) {\r\n            <span class=\"hljs-keyword\">if<\/span> (DEBUG) {\r\n                Log.e(TAG, <span class=\"hljs-string\">\"You MUST implement scrollToPosition. It will soon become abstract\"<\/span>);\r\n            }\r\n        }<\/code><\/pre>\n<p>\u4f46\u662f\u53ea\u91cd\u5199\u4ee5\u4e0a\u4e24\u4e2a\u65b9\u6cd5\u8fd8\u8fdc\u8fdc\u4e0d\u591f\uff0c\u6bd5\u7adfLayoutManager\u7684\u8d23\u4efb\u662f\u653e\u7f6e\u6240\u6709\u5b50View\u5230\u9002\u5f53\u7684\u4f4d\u7f6e\u4e0a\uff0c\u6240\u4ee5\u8fd8\u9700\u8981\u91cd\u5199onLayoutChildren()\u65b9\u6cd5\uff1a<\/p>\n<pre class=\"prettyprint\"><code class=\"hljs cs has-numbering\"><span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">void<\/span> <span class=\"hljs-title\">onLayoutChildren<\/span>(Recycler recycler, State state) {\r\n            Log.e(TAG, <span class=\"hljs-string\">\"You must override onLayoutChildren(Recycler recycler, State state) \"<\/span>);\r\n        }<\/code><\/pre>\n<h3 id=\"linearlayoutmanager\"><a name=\"t5\"><\/a>LinearlayoutManager<\/h3>\n<p>LinearLayoutManager\u662f\u76ee\u524dLayoutManager\u552f\u4e00\u7684\u9ed8\u8ba4\u5b9e\u73b0\uff0c\u53ef\u4ee5\u7528\u6765\u521b\u5efa\u6c34\u5e73\u6216\u8005\u5782\u76f4\u5217\u8868\u3002<\/p>\n<p>LinearLayout\u975e\u5e38\u590d\u6742\uff0c\u8fd9\u91cc\u53ea\u7b80\u5355\u8c08\u8c08\u5176\u4e2d\u4e00\u4e9b\u5173\u952e\u90e8\u5206\u3002LinearLayoutManager\u7684\u7528\u6cd5\u662f\u975e\u5e38\u7b80\u5355\u7684\uff1a\u521d\u59cb\u5316\u5b83\uff0c\u7136\u540e\u8bbe\u7f6e\u4e00\u4e2a\u65b9\u5411\uff08\u6c34\u5e73\/\u5782\u76f4\uff09\u5c31\u53ef\u4ee5\u4e86\uff1a<\/p>\n<pre class=\"prettyprint\"><code class=\"hljs avrasm has-numbering\">LinearLayoutManager layoutManager = new LinearLayoutManager(context)<span class=\"hljs-comment\">;<\/span>\r\nlayoutManager<span class=\"hljs-preprocessor\">.setOrientation<\/span>(LinearLayoutManager<span class=\"hljs-preprocessor\">.VERTICAL<\/span>)<span class=\"hljs-comment\">;<\/span>\r\nlayoutManager<span class=\"hljs-preprocessor\">.scrollToPosition<\/span>(currPos)<span class=\"hljs-comment\">;<\/span>\r\nrecyclerView<span class=\"hljs-preprocessor\">.setLayoutManager<\/span>(layoutManager)<span class=\"hljs-comment\">;<\/span><\/code><\/pre>\n<p>LinearLayoutManager\u8fd8\u63d0\u4f9b\u4e86\u4e00\u4e9b\u65b9\u6cd5\u7528\u6765\u67e5\u627e\u5f53\u524d\u5c4f\u5e55\u4e0a\u7684\u7b2c\u4e00\u4e2a\u548c\u6700\u540e\u4e00\u4e2a\u6761\u76ee\uff1a<\/p>\n<ul>\n<li>findFirstVisibleItemPosition()<\/li>\n<li>findFirstCompletelyVisibleItemPosition()<\/li>\n<li>findLastVisibleItemPosition()<\/li>\n<li>findLastCompletelyVisibleItemPosition()<\/li>\n<\/ul>\n<h2 id=\"recyclerviewitemdecoration\"><a name=\"t6\"><\/a>RecyclerView.ItemDecoration<\/h2>\n<p>\u4f7f\u7528ItemDecoration\u53ef\u4ee5\u7ed9\u6bcf\u4e2a\u6761\u76ee\u6dfb\u52a0\u504f\u79fb\u91cf\u3001\u53ef\u4ee5\u7ed9\u6761\u76ee\u95f4\u6dfb\u52a0\u95f4\u8ddd\u6216\u8005\u9ad8\u4eae\u6761\u76ee\uff0c\u6dfb\u52a0\u5176\u4ed6\u4fee\u9970\u6548\u679c\u7b49\u7b49\u3002<br \/>\nItemDecoration\u5e76\u4e0d\u662f\u5fc5\u987b\u4f7f\u7528\u7684\uff0c\u4f8b\u5982\u53ef\u4ee5\u4f7f\u7528CardView\u4f5c\u4e3a\u6bcf\u4e2a\u6761\u76ee\u7684\u89c6\u56fe\u3002<\/p>\n<p>\u53e6\u5916\uff0c\u53ef\u4ee5\u6dfb\u52a0\u4efb\u610f\u6570\u91cf\u7684ItemDecoration\uff0cRecyclerView\u4f1a\u904d\u5386\u6240\u6709\u7684ItemDecoration\u7136\u540e\u6309\u9002\u5f53\u987a\u5e8f\u8c03\u7528\u6bcf\u4e00\u4e2a\u7684\u7ed8\u5236\u65b9\u6cd5<\/p>\n<p>ItemDecoration\u865a\u57fa\u7c7b\u5305\u542b\u4ee5\u4e0b\u4e09\u4e2a\u65b9\u6cd5\uff1a<\/p>\n<ul>\n<li>public void onDraw(Canvas c, RecyclerView parent)<\/li>\n<li>public void onDrawOver(Canvas c, RecyclerView parent)<\/li>\n<li>public void getItemOffsets(Rect outRect, int itemPosition, RecyclerView parent)<\/li>\n<\/ul>\n<p>onDraw\u4e2d\u7ed8\u5236\u7684\u5185\u5bb9\u53ef\u80fd\u4f1a\u88ab\u6761\u76ee\u5185\u5bb9\u6240\u8986\u76d6\uff0c\u5982\u679c\u8981\u5728\u6761\u76ee\u4e0a\u7ed8\u5236\u5185\u5bb9\u9700\u8981\u4f7f\u7528onDrawOver()\u65b9\u6cd5\u3002\u5982\u679c\u9700\u8981\u6761\u76ee\u95f4\u8ddd\u6765\u7ed8\u5236\u5206\u5272\u7ebf\uff0c\u90a3\u4e48\u4f7f\u7528\u4ee5\u4e0a\u4e24\u4e2a\u65b9\u6cd5\u7684\u5dee\u522b\u4e0d\u5927\uff0c\u4f46\u662f\u5982\u679c\u771f\u7684\u8981\u6dfb\u52a0\u88c5\u9970\u6548\u679c\uff0c\u8fd8\u662f\u9700\u8981\u4f7f\u7528onDrawOver()\u3002<\/p>\n<p>LayoutManager\u5728\u6d4b\u91cf\u9636\u6bb5\u4f1a\u8c03\u7528getItemOffset()\u65b9\u6cd5\u6765\u6b63\u786e\u8ba1\u7b97\u6bcf\u4e2a\u6761\u76ee\u89c6\u56fe\u7684\u5927\u5c0f\u3002outRect\u53c2\u6570\u53ef\u80fd\u7b2c\u4e00\u773c\u770b\u6765\u6709\u4e9b\u5947\u602a\uff0c\u4e3a\u4ec0\u4e48\u4e0d\u4f7f\u7528\u4e00\u4e2a\u8fd4\u56de\u503c\u5462\uff1f\u4f46\u662f\u8fd9\u6837\u7684\u53c2\u6570\u8bbe\u7f6e\u786e\u5b9e\u662f\u6709\u610f\u4e49\u7684\uff0c\u5b83\u4f7f\u5f97\u5bf9\u4e8e\u6240\u6709\u7684\u5b50\u89c6\u56feRecyclerView\u53ef\u4ee5\u91cd\u7528\u540c\u4e00\u4e2aRect\u5bf9\u8c61\uff0c\u8282\u7701\u4e86\u8d44\u6e90\u5f00\u9500\u3002\u8fd9\u5e76\u4e0d\u662f\u5fc5\u987b\u7684\uff0c\u4f46\u786e\u5b9e\u662f\u5f88\u6709\u6548\u7387\u7684\u3002<\/p>\n<h2 id=\"recyclerviewitemanimator\"><a name=\"t7\"><\/a>RecyclerView.ItemAnimator<\/h2>\n<p>ItemAnimator\u53ef\u4ee5\u4e3a\u6bcf\u4e2a\u6761\u76ee\u6dfb\u52a0\u52a8\u753b\u6548\u679c\uff0c\u5b83\u4e3b\u8981\u5904\u7406\u4ee5\u4e0b\u4e09\u79cd\u4e8b\u4ef6\uff1a<\/p>\n<ul>\n<li>An item gets added to the data set<\/li>\n<li>An item gets removed from the data set<\/li>\n<li>An item moves as a result of one or more of the previous two operations<\/li>\n<\/ul>\n<p>ItemAnimator\u6709\u4e00\u4e2a\u9ed8\u8ba4\u5b9e\u73b0\uff1aDefaultItemAnimator\uff0c\u5982\u679c\u6ca1\u6709\u8bbe\u7f6e\u81ea\u5b9a\u4e49\u7684ItemAnimator\uff0cRecyclerView\u5c31\u4f1a\u4f7f\u7528\u9ed8\u8ba4\u7684DefaultItemAnimator\u3002<\/p>\n<p>\u663e\u7136\u5982\u679c\u8981\u8ba9\u52a8\u753b\u751f\u6548\uff0c\u9700\u8981\u77e5\u9053\u6570\u636e\u96c6\u5408\u7684\u53d8\u5316\uff0c\u8fd9\u9700\u8981Adapter\u7684\u5e2e\u52a9\u3002\u5728\u4e4b\u524d\u7684\u7248\u672c\u4e2d\uff0c\u5f53\u53d8\u5316\u53d1\u751f\u6539\u53d8\u65f6\uff0c\u9700\u8981\u8c03\u7528notifyDataSetChanged()\u65b9\u6cd5\u3002\u4f46\u8fd9\u662f\u4e0d\u5408\u9002\u7684\uff0c\u56e0\u4e3a\u8fd9\u4e2a\u65b9\u6cd5\u4f1a\u89e6\u53d1\u5bf9\u4e8e\u6240\u6709\u53ef\u89c6\u5b50View\u7684\u91cd\u7ed8\uff0c\u800c\u4e14\u6ca1\u6709\u52a8\u753b\u6548\u679c\u3002\u8981\u770b\u5230\u52a8\u753b\u6548\u679c\u9700\u8981\u4f7f\u7528\u66f4\u52a0\u7279\u6b8a\u7684\u65b9\u6cd5\uff1a<\/p>\n<p>RecyclerView.Adapter\u7c7b\u5305\u542b\u5f88\u591anotifyXXX()\u7c7b\u578b\u7684\u65b9\u6cd5\uff0c\u4e24\u4e2a\u6700\u5e38\u7528\u7684\u662f\uff1a<\/p>\n<ul>\n<li>public final void notifyItemInserted(int position)<\/li>\n<li>public final void notifyItemRemoved(int position)<\/li>\n<\/ul>\n<h2 id=\"\u76d1\u542c\u5668\"><a name=\"t8\"><\/a>\u76d1\u542c\u5668<\/h2>\n<p>RecyclerVIew\u63d0\u4f9b\u4e86\u4e00\u4e9b\u975e\u5e38\u901a\u7528\u7684\u76d1\u542c\u5668\u3002\u4e4b\u524d\u5e38\u89c1\u7684\u90a3\u4e9b\u4f7f\u7528\u65b9\u5f0f\u73b0\u5728\u90fd\u4e0d\u9002\u7528\u4e86\uff0cRecyclerView\u6ca1\u6709\u63d0\u4f9bOnItemClickListener\u6216\u8005OnItemLongClickListener\u3002\u4f46\u662f\u53ef\u4ee5\u4f7f\u7528RecyclerView.OnItemTouchListener\u7ed3\u5408\u624b\u52bf\u76d1\u542c\u6765\u5904\u7406\u8fd9\u4e9b\u4e8b\u4ef6\u3002\u9700\u8981\u7684\u7f16\u7801\u5de5\u4f5c\u5fc5\u4e4b\u524d\u8fbe\u5230\u540c\u6837\u7684\u6548\u679c\u8981\u591a\u3002<\/p>\n<h2 id=\"\u628a\u4ee5\u4e0a\u6240\u6709\u7c7b\u7ed3\u5408\u8d77\u6765\"><a name=\"t9\"><\/a>\u628a\u4ee5\u4e0a\u6240\u6709\u7c7b\u7ed3\u5408\u8d77\u6765<\/h2>\n<p>\u5e03\u5c40\u6587\u4ef6\uff1a<\/p>\n<pre class=\"prettyprint\"><code class=\"language-xml hljs  has-numbering\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-title\">RelativeLayout<\/span> <span class=\"hljs-attribute\">xmlns:android<\/span>=<span class=\"hljs-value\">\"http:\/\/schemas.android.com\/apk\/res\/android\"<\/span>\r\n    <span class=\"hljs-attribute\">xmlns:tools<\/span>=<span class=\"hljs-value\">\"http:\/\/schemas.android.com\/tools\"<\/span>\r\n    <span class=\"hljs-attribute\">android:layout_width<\/span>=<span class=\"hljs-value\">\"match_parent\"<\/span>\r\n    <span class=\"hljs-attribute\">android:layout_height<\/span>=<span class=\"hljs-value\">\"match_parent\"<\/span>\r\n    <span class=\"hljs-attribute\">android:paddingLeft<\/span>=<span class=\"hljs-value\">\"@dimen\/activity_horizontal_margin\"<\/span>\r\n    <span class=\"hljs-attribute\">android:paddingRight<\/span>=<span class=\"hljs-value\">\"@dimen\/activity_horizontal_margin\"<\/span>\r\n    <span class=\"hljs-attribute\">android:paddingTop<\/span>=<span class=\"hljs-value\">\"@dimen\/activity_vertical_margin\"<\/span>\r\n    <span class=\"hljs-attribute\">android:paddingBottom<\/span>=<span class=\"hljs-value\">\"@dimen\/activity_vertical_margin\"<\/span>\r\n    <span class=\"hljs-attribute\">tools:context<\/span>=<span class=\"hljs-value\">\".RecyclerViewDemoActivity\"<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-title\">android.support.v7.widget.RecyclerView\r\n<\/span>        <span class=\"hljs-attribute\">android:id<\/span>=<span class=\"hljs-value\">\"@+id\/recyclerView\"<\/span>\r\n        <span class=\"hljs-attribute\">android:layout_width<\/span>=<span class=\"hljs-value\">\"match_parent\"<\/span>\r\n        <span class=\"hljs-attribute\">android:layout_height<\/span>=<span class=\"hljs-value\">\"match_parent\"<\/span>\r\n        <span class=\"hljs-attribute\">tools:context<\/span>=<span class=\"hljs-value\">\".MainActivity\"<\/span>\r\n        <span class=\"hljs-attribute\">tools:listitem<\/span>=<span class=\"hljs-value\">\"@layout\/item_demo_01\"<\/span>\/&gt;<\/span>\r\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-title\">ImageButton\r\n<\/span>        <span class=\"hljs-attribute\">android:id<\/span>=<span class=\"hljs-value\">\"@+id\/fab_add\"<\/span>\r\n        <span class=\"hljs-attribute\">android:layout_alignParentRight<\/span>=<span class=\"hljs-value\">\"true\"<\/span>\r\n        <span class=\"hljs-attribute\">android:layout_alignParentBottom<\/span>=<span class=\"hljs-value\">\"true\"<\/span>\r\n        <span class=\"hljs-attribute\">android:layout_width<\/span>=<span class=\"hljs-value\">\"@dimen\/fab_size\"<\/span>\r\n        <span class=\"hljs-attribute\">android:layout_height<\/span>=<span class=\"hljs-value\">\"@dimen\/fab_size\"<\/span>\r\n        <span class=\"hljs-attribute\">android:layout_gravity<\/span>=<span class=\"hljs-value\">\"bottom|right\"<\/span>\r\n        <span class=\"hljs-attribute\">android:layout_marginRight<\/span>=<span class=\"hljs-value\">\"16dp\"<\/span>\r\n        <span class=\"hljs-attribute\">android:layout_marginBottom<\/span>=<span class=\"hljs-value\">\"16dp\"<\/span>\r\n        <span class=\"hljs-attribute\">android:background<\/span>=<span class=\"hljs-value\">\"@drawable\/ripple\"<\/span>\r\n        <span class=\"hljs-attribute\">android:stateListAnimator<\/span>=<span class=\"hljs-value\">\"@anim\/anim\"<\/span>\r\n        <span class=\"hljs-attribute\">android:src<\/span>=<span class=\"hljs-value\">\"@drawable\/ic_action_add\"<\/span>\r\n        <span class=\"hljs-attribute\">android:elevation<\/span>=<span class=\"hljs-value\">\"1dp\"<\/span>\/&gt;<\/span>\r\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-title\">RelativeLayout<\/span>&gt;<\/span><\/code><\/pre>\n<p>RecyclerView\u7684AttributeSet\u4f1a\u5728generateLayoutParams()\u65b9\u6cd5\u4e2d\u4f7f\u7528\uff1a<\/p>\n<pre class=\"prettyprint\"><code class=\"hljs java has-numbering\"><span class=\"hljs-annotation\">@Override<\/span>\r\n<span class=\"hljs-keyword\">public<\/span> ViewGroup.LayoutParams <span class=\"hljs-title\">generateLayoutParams<\/span>(AttributeSet attrs) {\r\n   <span class=\"hljs-keyword\">if<\/span> (mLayout == <span class=\"hljs-keyword\">null<\/span>) {\r\n      <span class=\"hljs-keyword\">throw<\/span> <span class=\"hljs-keyword\">new<\/span> IllegalStateException(<span class=\"hljs-string\">\"RecyclerView has no LayoutManager\"<\/span>);\r\n   }\r\n   <span class=\"hljs-keyword\">return<\/span> mLayout.generateLayoutParams(getContext(), attrs);\r\n}<\/code><\/pre>\n<p>\u7a0b\u5e8f\u4ee3\u7801\u90e8\u5206\u5f88\u7b80\u5355\uff1a<\/p>\n<pre class=\"prettyprint\"><code class=\"language-Android hljs vhdl has-numbering\">setContentView(R.layout.activity_recyclerview_demo);\r\nrecyclerView = (RecyclerView) findViewById(R.id.recyclerView);\r\n\r\nLinearLayoutManager layoutManager = <span class=\"hljs-keyword\">new<\/span> LinearLayoutManager(this);\r\nlayoutManager.setOrientation(LinearLayoutManager.VERTICAL);\r\nlayoutManager.scrollToPosition(<span class=\"hljs-number\">0<\/span>);\r\nrecyclerView.setLayoutManager(layoutManager);\r\n\r\n\/\/ allows <span class=\"hljs-keyword\">for<\/span> optimizations <span class=\"hljs-keyword\">if<\/span> <span class=\"hljs-keyword\">all<\/span> item views are <span class=\"hljs-keyword\">of<\/span> the same size:\r\nrecyclerView.setHasFixedSize(true);\r\n\r\n\/\/ <span class=\"hljs-keyword\">For<\/span> the sake <span class=\"hljs-keyword\">of<\/span> simplicity I misused the Application subclass as a DAO\r\nList&lt;DemoModel&gt; items = RecyclerViewDemoApp.getDemoData();\r\nadapter = <span class=\"hljs-keyword\">new<\/span> RecyclerViewDemoAdapter(items);\r\nrecyclerView.setAdapter(adapter);\r\n\r\nRecyclerView.ItemDecoration itemDecoration =\r\n        <span class=\"hljs-keyword\">new<\/span> DividerItemDecoration(this, DividerItemDecoration.VERTICAL_LIST);\r\nrecyclerView.addItemDecoration(itemDecoration);\r\n\r\n\/\/ this <span class=\"hljs-keyword\">is<\/span> the <span class=\"hljs-keyword\">default<\/span>; \r\n\/\/ this call <span class=\"hljs-keyword\">is<\/span> actually only necessary <span class=\"hljs-keyword\">with<\/span> custom ItemAnimators\r\nrecyclerView.setItemAnimator(<span class=\"hljs-keyword\">new<\/span> DefaultItemAnimator());\r\n\r\n\/\/ onClickDetection <span class=\"hljs-keyword\">is<\/span> done <span class=\"hljs-keyword\">in<\/span> this Activity<span class=\"hljs-attribute\">'s<\/span> OnItemTouchListener\r\n\/\/ <span class=\"hljs-keyword\">with<\/span> the help <span class=\"hljs-keyword\">of<\/span> a GestureDetector;\r\n\/\/ Tip by Ian Lake <span class=\"hljs-keyword\">on<\/span> G+ <span class=\"hljs-keyword\">in<\/span> a comment <span class=\"hljs-keyword\">to<\/span> this post:\r\n\/\/ https:\/\/plus.google.com\/+LucasRocha\/posts\/<span class=\"hljs-number\">37<\/span>U8GWtYxDE\r\nrecyclerView.addOnItemTouchListener(this);\r\ngesturedetector =\r\n        <span class=\"hljs-keyword\">new<\/span> GestureDetectorCompat(this, <span class=\"hljs-keyword\">new<\/span> RecyclerViewDemoOnGestureListener());<\/code><\/pre>\n<p>\u4e3b\u8981\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<ol>\n<li>\u83b7\u53d6RecyclerView\u7684\u5f15\u7528<\/li>\n<li>\u521b\u5efa\u4e00\u4e2aLayoutManager\u5e76\u6dfb\u52a0<\/li>\n<li>\u521b\u5efa\u4e00\u4e2aAdapter\u5e76\u6dfb\u52a0<\/li>\n<li>\u5982\u679c\u9700\u8981\u7684\u8bdd\uff0c\u521b\u5efa1\u4e2a\u6216\u591a\u4e2aItemDecoration\u5e76\u6dfb\u52a0<\/li>\n<li>\u5982\u679c\u9700\u8981\u7684\u8bdd\uff0c\u521b\u5efaItemAnimator\u5e76\u6dfb\u52a0<\/li>\n<li>\u5982\u679c\u9700\u8981\u7684\u8bdd\uff0c\u521b\u5efa1\u4e2a\u6216\u591a\u4e2a\u76d1\u542c\u5668\u5e76\u6dfb\u52a0<\/li>\n<\/ol>\n<p>\u5f53\u7136\u8fd9\u53ea\u662f\u521d\u6b65\u7684\u4ee3\u7801\uff0c\u771f\u6b63\u6709\u8da3\u7684\u90e8\u5206\u5728\u4e8eRecyclerView\u6709\u5f88\u591a\u5185\u90e8\u7c7b\uff0c\u53ef\u4ee5\u7528\u6765\u7ee7\u627f\u5e76\u4e14\u5b9e\u73b0\u5404\u79cd\u81ea\u5b9a\u4e49\u7684\u6548\u679c\uff0c\u8fd9\u624d\u662f\u771f\u6b63\u9700\u8981\u6295\u5165\u5927\u91cf\u5de5\u4f5c\u7684\u5730\u65b9\u3002<\/p>\n<p>\u539f\u6587\u51fa\u5904\uff1a<a href=\"http:\/\/blog.csdn.net\/wanglu198506\/article\/details\/43898131\">RecyclerView\u521d\u63a2<\/a><\/p>\n<p>\u539f\u6587\u5730\u5740\uff1a<a href=\"http:\/\/www.grokkingandroid.com\/first-glance-androids-recyclerview\/\">http:\/\/www.grokkingandroid.com\/first-glance-androids-recyclerview\/<\/a><\/p>\n<p>\u672c\u6587\u793a\u4f8b\u4ee3\u7801\u9879\u76ee\u5730\u5740\uff1a<a href=\"https:\/\/github.com\/writtmeyer\/recyclerviewdemo\">https:\/\/github.com\/writtmeyer\/recyclerviewdemo<\/a><\/p>\n<p>\u53c2\u8003:\u00a0<a href=\"http:\/\/jcodecraeer.com\/a\/anzhuokaifa\/androidkaifa\/2014\/1118\/2004.html\">RecyclerView\u4f7f\u7528\u4ecb\u7ecd<\/a><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u5e94\u8be5\u662f\u521d\u6b65\u4e86\u89e3RecyclerView\u5168\u8c8c\u7684\u6700\u4f73\u6587\u7ae0\u3002 RecyclerView\u662f\u53bb\u5e74\u8c37\u6b4cI\/O\u5927\u4f1a\u4e0a\u968fAn [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[75],"_links":{"self":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/1189"}],"collection":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1189"}],"version-history":[{"count":3,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/1189\/revisions"}],"predecessor-version":[{"id":1205,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/1189\/revisions\/1205"}],"wp:attachment":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1189"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1189"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1189"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}