{"id":36505,"date":"2024-11-26T13:15:50","date_gmt":"2024-11-26T05:15:50","guid":{"rendered":"https:\/\/fwq.ai\/blog\/36505\/"},"modified":"2024-11-26T13:15:50","modified_gmt":"2024-11-26T05:15:50","slug":"%e5%ae%89%e5%8d%93%e8%87%aa%e5%ae%9a%e4%b9%89%e9%80%82%e9%85%8d%e5%99%a8%e6%a0%b7%e5%bc%8f%e4%b8%a2%e5%a4%b1%ef%bc%9a%e4%b8%ba%e4%bb%80%e4%b9%88%e5%bc%95%e7%94%a8%e6%a0%b7%e5%bc%8f%e4%bc%9a%e6%8f%90","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/36505\/","title":{"rendered":"\u5b89\u5353\u81ea\u5b9a\u4e49\u9002\u914d\u5668\u6837\u5f0f\u4e22\u5931\uff1a\u4e3a\u4ec0\u4e48\u5f15\u7528\u6837\u5f0f\u4f1a\u63d0\u793a\u201c\u65e0\u6cd5\u89e3\u91ca\u7b26\u53f7 mainitem\u201d\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173123154453396.jpg\" class=\"aligncenter\" title=\"\u5b89\u5353\u81ea\u5b9a\u4e49\u9002\u914d\u5668\u6837\u5f0f\u4e22\u5931\uff1a\u4e3a\u4ec0\u4e48\u5f15\u7528\u6837\u5f0f\u4f1a\u63d0\u793a\u201c\u65e0\u6cd5\u89e3\u91ca\u7b26\u53f7 mainitem\u201d\uff1f\u63d2\u56fe\" alt=\"\u5b89\u5353\u81ea\u5b9a\u4e49\u9002\u914d\u5668\u6837\u5f0f\u4e22\u5931\uff1a\u4e3a\u4ec0\u4e48\u5f15\u7528\u6837\u5f0f\u4f1a\u63d0\u793a\u201c\u65e0\u6cd5\u89e3\u91ca\u7b26\u53f7 mainitem\u201d\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5b89\u5353\u81ea\u5b9a\u4e49\u9002\u914d\u5668\u6837\u5f0f\u4e22\u5931\u95ee\u9898<\/strong><\/p>\n<p>\u5728\u5b89\u5353\u5e94\u7528\u5f00\u53d1\u4e2d\uff0c\u81ea\u5b9a\u4e49\u9002\u914d\u5668\u662f\u5904\u7406\u4e0d\u540c\u7c7b\u578b\u89c6\u56fe\u7684\u5e38\u89c1\u65b9\u6cd5\u3002\u4f46\u662f\uff0c\u6709\u65f6\u5728\u81ea\u5b9a\u4e49\u9002\u914d\u5668\u4e2d\u53ef\u80fd\u9047\u5230\u6837\u5f0f\u4e22\u5931\u7684\u95ee\u9898\uff0c\u5bfc\u81f4\u89c6\u56fe\u663e\u793a\u4e0d\u5f53\u3002\u672c\u6587\u5c06\u63a2\u8ba8\u4e00\u4e2a\u5e38\u89c1\u7684\u6837\u5f0f\u4e22\u5931\u95ee\u9898\uff0c\u5e76\u63d0\u4f9b\u89e3\u51b3\u65b9\u6848\u3002<\/p>\n<p><strong>\u95ee\u9898<\/strong><\/p>\n<p>\u5728\u81ea\u5b9a\u4e49\u9002\u914d\u5668\u4e2d\uff0c\u5de6\u8fb9\u5df2\u5efa\u7acb\u7684\u6837\u5f0f\u65e0\u6cd5\u5e94\u7528\u5230\u53f3\u8fb9\u81ea\u5b9a\u4e49\u7684\u5bf9\u8c61\u4e0a\u3002\u5f53\u8bd5\u56fe\u5f15\u7528\u6837\u5f0f\u65f6\uff0c\u4f1a\u63d0\u793a\u201c\u65e0\u6cd5\u89e3\u91ca\u7b26\u53f7 mnitem\u201d\u3002<\/p>\n<p><strong>\u539f\u56e0<\/strong><\/p>\n<p>\u8be5\u95ee\u9898\u901a\u5e38\u662f\u7531\u9519\u8bef\u5730\u5bfc\u5165 r \u6587\u4ef6\u5f15\u8d77\u7684\u3002android \u7cfb\u7edf\u5305\u4e2d\u5305\u542b\u81ea\u5df1\u7684 r \u6587\u4ef6\uff0c\u800c\u5e94\u7528\u9879\u76ee\u4e5f\u6709\u81ea\u5df1\u7684 r \u6587\u4ef6\u3002\u5728\u81ea\u5b9a\u4e49\u9002\u914d\u5668\u4e2d\uff0c\u5e94\u8be5\u5bfc\u5165\u9879\u76ee\u81ea\u5df1\u7684 r \u6587\u4ef6\uff0c\u800c\u4e0d\u662f\u7cfb\u7edf r \u6587\u4ef6\u3002<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848<\/strong><\/p>\n<p>\u8981\u89e3\u51b3\u6b64\u95ee\u9898\uff0c\u8bf7\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u64cd\u4f5c\uff1a<\/p>\n<ol>\n<li>\n<p>\u4ece\u81ea\u5b9a\u4e49\u9002\u914d\u5668\u4e2d\u79fb\u9664 android.r \u6587\u4ef6\u7684\u5bfc\u5165\uff1a<\/p>\n<pre>-import android.r;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<li>\n<p>\u5bfc\u5165\u9879\u76ee\u5f53\u524d\u5305\u540d\u4e0b\u7684 r \u6587\u4ef6\uff1a<\/p>\n<pre>+import [package_name].r;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<\/ol>\n<p>\u66f4\u65b0\u540e\u7684\u81ea\u5b9a\u4e49\u9002\u914d\u5668\u4ee3\u7801\u793a\u4f8b\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre>import [package_name].R;\n\npublic class CustomAdapter extends ArrayAdapter&lt;String&gt; {\n\n    public CustomAdapter(Context context, String[] objects) {\n        super(context, R.layout.main_item, objects);\n    }\n\n    @Override\n    public View getView(int position, View convertView, ViewGroup parent) {\n        \/\/ ...\n        return view;\n    }\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u901a\u8fc7\u6b63\u786e\u5bfc\u5165 r \u6587\u4ef6\uff0c\u81ea\u5b9a\u4e49\u9002\u914d\u5668\u73b0\u5728\u80fd\u591f\u8bbf\u95ee\u9879\u76ee\u4e2d\u7684\u6837\u5f0f\uff0c\u4ece\u800c\u89e3\u51b3\u6837\u5f0f\u4e22\u5931\u95ee\u9898\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5b89\u5353\u81ea\u5b9a\u4e49\u9002\u914d\u5668\u6837\u5f0f\u4e22\u5931\uff1a\u5f15\u7528\u6837\u5f0f\u4f1a\u63d0\u793a\u201c\u65e0\u6cd5\u89e3\u91ca\u7b26\u53f7 mnitem\u201d\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b89\u5353\u81ea\u5b9a\u4e49\u9002\u914d\u5668\u6837\u5f0f\u4e22\u5931\u95ee\u9898 \u5728\u5b89\u5353\u5e94\u7528\u5f00\u53d1\u4e2d\uff0c\u81ea\u5b9a\u4e49\u9002\u914d\u5668\u662f\u5904\u7406\u4e0d\u540c\u7c7b\u578b\u89c6\u56fe\u7684\u5e38\u89c1\u65b9\u6cd5\u3002\u4f46\u662f\uff0c\u6709\u65f6\u5728\u81ea\u5b9a\u4e49\u9002\u914d\u5668\u4e2d\u53ef\u80fd\u9047\u5230\u6837\u5f0f\u4e22\u5931\u7684\u95ee\u9898\uff0c\u5bfc\u81f4\u89c6\u56fe\u663e\u793a\u4e0d\u5f53\u3002\u672c\u6587\u5c06\u63a2\u8ba8\u4e00\u4e2a\u5e38\u89c1\u7684\u6837\u5f0f\u4e22\u5931\u95ee\u9898\uff0c\u5e76\u63d0\u4f9b\u89e3\u51b3\u65b9\u6848\u3002 \u95ee\u9898 \u5728\u81ea\u5b9a\u4e49\u9002\u914d\u5668\u4e2d\uff0c\u5de6\u8fb9\u5df2\u5efa\u7acb\u7684\u6837\u5f0f\u65e0\u6cd5\u5e94\u7528\u5230\u53f3\u8fb9\u81ea\u5b9a\u4e49\u7684\u5bf9\u8c61\u4e0a\u3002\u5f53\u8bd5\u56fe\u5f15\u7528\u6837\u5f0f\u65f6\uff0c\u4f1a\u63d0\u793a\u201c\u65e0\u6cd5\u89e3\u91ca\u7b26\u53f7 mnitem\u201d\u3002 \u539f\u56e0 \u8be5\u95ee\u9898\u901a\u5e38\u662f\u7531\u9519\u8bef\u5730\u5bfc\u5165 r \u6587\u4ef6\u5f15\u8d77\u7684\u3002android \u7cfb\u7edf\u5305\u4e2d\u5305\u542b\u81ea\u5df1\u7684 r \u6587\u4ef6\uff0c\u800c\u5e94\u7528\u9879\u76ee\u4e5f\u6709\u81ea\u5df1\u7684 r \u6587\u4ef6\u3002\u5728\u81ea\u5b9a\u4e49\u9002\u914d\u5668\u4e2d\uff0c\u5e94\u8be5\u5bfc\u5165\u9879\u76ee\u81ea\u5df1\u7684 r \u6587\u4ef6\uff0c\u800c\u4e0d\u662f\u7cfb\u7edf r \u6587\u4ef6\u3002 \u89e3\u51b3\u65b9\u6848 \u8981\u89e3\u51b3\u6b64\u95ee\u9898\uff0c\u8bf7\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u64cd\u4f5c\uff1a \u4ece\u81ea\u5b9a\u4e49\u9002\u914d\u5668\u4e2d\u79fb\u9664 android.r \u6587\u4ef6\u7684\u5bfc\u5165\uff1a -import android.r; \u767b\u5f55\u540e\u590d\u5236 \u5bfc\u5165\u9879\u76ee\u5f53\u524d\u5305\u540d\u4e0b\u7684 r \u6587\u4ef6\uff1a +import [package_name].r; \u767b\u5f55\u540e\u590d\u5236 \u66f4\u65b0\u540e\u7684\u81ea\u5b9a\u4e49\u9002\u914d\u5668\u4ee3\u7801\u793a\u4f8b\u5982\u4e0b\u6240\u793a\uff1a import [package_name].R; public class CustomAdapter extends ArrayAdapter&lt;String&gt; { public CustomAdapter(Context context, String[] objects) { super(context, R.layout.main_item, objects); } @Override public View getView(int [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-36505","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/36505","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=36505"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/36505\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=36505"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=36505"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=36505"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}