{"id":478,"date":"2012-10-28T01:20:49","date_gmt":"2012-10-27T17:20:49","guid":{"rendered":"http:\/\/guoh.ai\/lifelog\/?p=478"},"modified":"2013-12-31T14:33:13","modified_gmt":"2013-12-31T06:33:13","slug":"and-expandable-listview-with-different-types-of-item-views","status":"publish","type":"post","link":"https:\/\/guoh.ai\/lifelog\/2012\/10\/and-expandable-listview-with-different-types-of-item-views\/","title":{"rendered":"Android ExpandableListView\u653e\u7f6e\u4e0d\u540c\u7c7b\u578b\u7684\u89c6\u56fe"},"content":{"rendered":"<p>\u901a\u5e38\u7684<a href=\"http:\/\/developer.android.com\/reference\/android\/widget\/ExpandableListView.html\" target=\"_blank\">ExpandableListView<\/a>\u7684group item\u662f\u4e00\u79cd\u89c6\u56fe\uff0cchild item\u662f\u53e6\u5916\u4e00\u79cd\u89c6\u56fe\uff0c\u540c\u4e00\u79cditem\u4e0d\u4f1a\u51fa\u73b0\u591a\u79cd\u7c7b\u578b\u7684\u89c6\u56fe\uff0c\u8fd9\u662f\u9ed8\u8ba4\u7684\u8bbe\u8ba1\u3002\u4f46\u662f\u6211\u4eec\u6709\u65f6\u5019\u4e3a\u4e86\u5b9e\u73b0\u66f4\u4e3a\u590d\u6742\u7684\u754c\u9762\uff0c\u5c31\u9700\u8981ExpandableListView\u652f\u63f4\u540c\u4e00\u7c7b\u578b\u7684item\u653e\u7f6e\u4e0d\u540c\u7c7b\u578b\u7684\u89c6\u56fe\u3002\u5176\u5b9e\u505a\u6cd5\u4e5f\u5f88\u7b80\u5355\uff0c\u5c31\u662fAdapter\u9700\u8981\u5b9e\u73b0<a href=\"http:\/\/developer.android.com\/reference\/android\/widget\/HeterogeneousExpandableList.html\" target=\"_blank\">HeterogeneousExpandableList<\/a>\u63a5\u53e3\u7684getChildType\uff0cgetChildTypeCount\uff0cgetGroupType\u548cgetGroupTypeCount\u8fd9\u56db\u4e2a\u65b9\u6cd5\u3002\u56e0\u4e3aExpandableListView\u4e3a\u4e86\u6548\u7387\u7684\u56e0\u7d20\uff0c\u5b83\u7684item\u7684\u89c6\u56fe\u662freuse\u7684\uff0c\u5982\u679c\u4e0d\u6307\u5b9a\u5404\u4e2aitem\u6240\u7528\u89c6\u56fe\u7684\u7c7b\u578b\uff0cExpandableListView\u5c31\u4f1a\u9ed8\u8ba4\u91c7\u7528\u7b2c\u4e00\u4e2a\u89c6\u56fe\uff0c\u6240\u4ee5\u5982\u679c\u4e0d\u5b9e\u73b0\u8fd9\u56db\u4e2a\u65b9\u6cd5\uff0c\u5448\u73b0\u51fa\u6765\u7684\u754c\u9762\u5c31\u662f\u9519\u8bef\u7684\uff0c\u6216\u8005\u7a0b\u5e8f\u76f4\u63a5\u4f1acrash\u3002\u8be6\u7ec6\u4f8b\u5b50\u53ef\u4ee5\u53c2\u89c1<a href=\"https:\/\/github.com\/guohai\/and-expandable-listview\" target=\"_blank\">https:\/\/github.com\/guohai\/and-expandable-listview<\/a> \u3002\u6548\u679c\u5982\u4e0b\u56fe\uff1a<br \/>\n<a href=\"https:\/\/www.flickr.com\/photos\/46848122@N08\/8128147375\/\" title=\"and-expandable-listview by DeliberateKids, on Flickr\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/farm9.staticflickr.com\/8193\/8128147375_a5ca7b580c_c.jpg\" width=\"480\" height=\"800\" alt=\"and-expandable-listview\" target=\"_blank\"><\/a><br \/>\n<strong>\u6ce8\u610f\u70b9\uff1a<\/strong>getChildTypeCount\u662f\u7528\u5230\u6240\u6709\u4e0d\u540c\u7c7b\u578b\u7684child item\u7684\u603b\u6570\uff0c\u4e0d\u7ba1\u662f\u540c\u4e00group item\u4e0b\u7684\u4e0d\u540c\u7c7b\u578b\uff0c\u8fd8\u662f\u4e0d\u540cgroup item\u4e0b\u7684\u4e0d\u540c\u7c7b\u578b\uff0c\u53ea\u8981\u91cd\u590d\u5c31\u53ea\u7b97\u4e00\u6b21\u3002getGroupTypeCount\u4e5f\u662f\u5982\u6b64\u3002<br \/>\ngetChildType\u6216\u8005getGroupType\u662f\u8fd4\u56de\u4f4d\u7f6e\uff0c\u6240\u4ee5\u90fd\u662f\u4ece0\u5f00\u59cb\u7684\uff0c\u4e0d\u8d85\u8fc7\u6700\u540e\u4e00\u4e2a\u4e0d\u91cd\u590d\u7684child\u6216\u8005group item\u7684\u4f4d\u7f6e\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u901a\u5e38\u7684ExpandableListView\u7684group item\u662f\u4e00\u79cd\u89c6\u56fe\uff0cchild item\u662f\u53e6\u5916\u4e00\u79cd\u89c6\u56fe\uff0c\u540c\u4e00\u79cditem\u4e0d\u4f1a\u51fa\u73b0\u591a\u79cd\u7c7b\u578b\u7684\u89c6\u56fe\uff0c\u8fd9\u662f\u9ed8\u8ba4\u7684\u8bbe\u8ba1\u3002\u4f46\u662f\u6211\u4eec\u6709\u65f6\u5019\u4e3a\u4e86\u5b9e\u73b0\u66f4\u4e3a\u590d\u6742\u7684\u754c\u9762\uff0c\u5c31\u9700\u8981ExpandableListView\u652f\u63f4\u540c\u4e00\u7c7b\u578b\u7684item\u653e\u7f6e\u4e0d\u540c\u7c7b\u578b\u7684\u89c6\u56fe\u3002\u5176\u5b9e\u505a\u6cd5\u4e5f\u5f88\u7b80\u5355\uff0c\u5c31\u662fAdapter\u9700\u8981\u5b9e\u73b0HeterogeneousExpandableList\u63a5\u53e3\u7684getChildType\uff0cgetChildTypeCount\uff0cgetGroupType\u548cgetGroupTypeCount\u8fd9\u56db\u4e2a\u65b9\u6cd5\u3002\u56e0\u4e3aExpandableListView\u4e3a\u4e86\u6548\u7387\u7684\u56e0\u7d20\uff0c\u5b83\u7684item\u7684\u89c6\u56fe\u662freuse\u7684\uff0c\u5982\u679c\u4e0d\u6307\u5b9a\u5404\u4e2aitem\u6240\u7528\u89c6\u56fe\u7684\u7c7b\u578b\uff0cExpandableListView\u5c31\u4f1a\u9ed8\u8ba4\u91c7\u7528\u7b2c\u4e00\u4e2a\u89c6\u56fe\uff0c\u6240\u4ee5\u5982\u679c\u4e0d\u5b9e\u73b0\u8fd9\u56db\u4e2a\u65b9\u6cd5\uff0c\u5448\u73b0\u51fa\u6765\u7684\u754c\u9762\u5c31\u662f\u9519\u8bef\u7684\uff0c\u6216\u8005\u7a0b\u5e8f\u76f4\u63a5\u4f1acrash\u3002\u8be6\u7ec6\u4f8b\u5b50\u53ef\u4ee5\u53c2\u89c1https:\/\/github.com\/guohai\/and-expandable-listview \u3002\u6548\u679c\u5982\u4e0b\u56fe\uff1a \u6ce8\u610f\u70b9\uff1agetChildTypeCount\u662f\u7528\u5230\u6240\u6709\u4e0d\u540c\u7c7b\u578b\u7684child item\u7684\u603b\u6570\uff0c\u4e0d\u7ba1\u662f\u540c\u4e00group item\u4e0b\u7684\u4e0d\u540c\u7c7b\u578b\uff0c\u8fd8\u662f\u4e0d\u540cgroup item\u4e0b\u7684\u4e0d\u540c\u7c7b\u578b\uff0c\u53ea\u8981\u91cd\u590d\u5c31\u53ea\u7b97\u4e00\u6b21\u3002getGroupTypeCount\u4e5f\u662f\u5982\u6b64\u3002 getChildType\u6216\u8005getGroupType\u662f\u8fd4\u56de\u4f4d\u7f6e\uff0c\u6240\u4ee5\u90fd\u662f\u4ece0\u5f00\u59cb\u7684\uff0c\u4e0d\u8d85\u8fc7\u6700\u540e\u4e00\u4e2a\u4e0d\u91cd\u590d\u7684child\u6216\u8005group item\u7684\u4f4d\u7f6e\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_gfmr_meta_descriptions":[],"_gfmr_multilingual_taxonomy_terms":[],"footnotes":""},"categories":[7],"tags":[],"class_list":["post-478","post","type-post","status-publish","format-standard","hentry","category-android"],"_links":{"self":[{"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/posts\/478","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/comments?post=478"}],"version-history":[{"count":6,"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/posts\/478\/revisions"}],"predecessor-version":[{"id":885,"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/posts\/478\/revisions\/885"}],"wp:attachment":[{"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/media?parent=478"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/categories?post=478"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/tags?post=478"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}