﻿{"id":778,"date":"2011-01-05T10:44:08","date_gmt":"2011-01-05T02:44:08","guid":{"rendered":"http:\/\/www.tansoo.cn\/?p=778"},"modified":"2014-09-11T10:45:37","modified_gmt":"2014-09-11T02:45:37","slug":"%e5%ad%a6%e4%b9%a0%e7%ac%94%e8%ae%b0%ef%bc%9aandroid%e6%8e%a7%e4%bb%b6listview%e7%9a%84%e7%ae%80%e5%8d%95%e4%bd%bf%e7%94%a8%e6%96%b9%e6%b3%95%e3%80%82","status":"publish","type":"post","link":"http:\/\/www.tansoo.cn\/?p=778","title":{"rendered":"\u5b66\u4e60\u7b14\u8bb0\uff1aAndroid\u63a7\u4ef6ListView\u7684\u7b80\u5355\u4f7f\u7528\u65b9\u6cd5\u3002"},"content":{"rendered":"<p>\u8fd1\u6bb5\u65f6\u95f4\u5229\u7528\u5de5\u4f59\u65f6\u95f4\u7ee7\u7eedAndroid\u7684\u5b66\u4e60\uff0c\u8bd5\u4e86\u4e00\u4e0bListView\u7684\u7528\u6cd5\u3002\u4ece\u7f51\u4e0a\u67e5\u770b\u7684\u8d44\u6599\u975e\u5e38\u591a\uff0c\u65b9\u6cd5\u4e5f\u5f88\u7075\u6d3b\uff0c\u6211\u5148\u5b66\u4e00\u4e0b\u5b83\u7684\u6700\u7b80\u5355\u65b9\u6cd5\uff0c\u4e3aListView\u6dfb\u52a0\u6570\u636e\u3002\u8fd9\u6b21\u8bd5\u4e86\u7528\u4e24\u79cd\u65b9\u6cd5\u5411ListView\u6dfb\u52a0\u5b57\u7b26\u4e32\u6570\u7ec4\uff0c\u4e00\u6b21\u53ea\u7528\u4e00\u4e2a\u54c8\u3002 <\/p>\n<pre class=\"lang:java decode:true \" >public class MainActivity extends Activity {\r\n\r\n\t@Override\r\n\tprotected void onCreate(Bundle savedInstanceState) {\r\n\t\tsuper.onCreate(savedInstanceState);\r\n\t\tsetContentView(R.layout.activity_main);\r\n\r\n\t\t\/\/\u7ed9ListView\u6dfb\u52a0\u5185\u5bb9\u7684\u4e00\u79cd\u65b9\u6cd5\u3002\r\n\t\tListView list1 = new ListView(this);\r\n\t\tlist1.findViewById(R.id.listView1);\r\n\r\n\t\tString[] array_str = new String[] { \"a\", \"b\", \"c\" };\r\n\t\tArrayAdapter&lt;String&gt; str_list1 = new ArrayAdapter&lt;String&gt;(this,\r\n\t\t\t\tandroid.R.layout.simple_list_item_1,array_str);\r\n\t\tlist1.setAdapter(str_list1);\r\n\t\tsetContentView(list1);\r\n\r\n\t\t\/\/\u7ed9ListView\u6dfb\u52a0\u5185\u5bb9\u7684\u53e6\u4e00\u79cd\u65b9\u6cd5\uff0c\u8fd9\u79cd\u65b9\u6cd5\u6bd4\u8f83\u7075\u6d3b\uff0c\u60f3\u770b\u8fd0\u884c\u6548\u679c\u5c31\u4e00\u6b21\u53ea\u8fd0\u884c\u4e00\u4e2a\u54c8\r\n\t\tListView list2 = new ListView(this);\r\n\t\tlist2.findViewById(R.id.listView2);\r\n\r\n\t\tArrayAdapter&lt;String&gt; str_list2 = new ArrayAdapter&lt;String&gt;(this,\r\n\t\t\t\tandroid.R.layout.simple_list_item_1);\r\n\t\tstr_list2.add(\"A\");\r\n\t\tstr_list2.add(\"B\");\r\n\t\tstr_list2.add(\"C\");\r\n\t\tlist2.setAdapter(str_list2);\r\n\t\tsetContentView(list2);\r\n\t}\r\n\r\n\t@Override\r\n\tpublic boolean onCreateOptionsMenu(Menu menu) {\r\n\t\t\/\/ Inflate the menu; this adds items to the action bar if it is present.\r\n\t\tgetMenuInflater().inflate(R.menu.main, menu);\r\n\t\treturn true;\r\n\t}\r\n\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u8fd1\u6bb5\u65f6\u95f4\u5229\u7528\u5de5\u4f59\u65f6\u95f4\u7ee7\u7eedAndroid\u7684\u5b66\u4e60\uff0c\u8bd5\u4e86\u4e00\u4e0bListView\u7684\u7528\u6cd5\u3002\u4ece\u7f51\u4e0a\u67e5\u770b\u7684\u8d44\u6599\u975e\u5e38\u591a\uff0c\u65b9\u6cd5\u4e5f\u5f88 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[34],"class_list":["post-778","post","type-post","status-publish","format-standard","hentry","category-program","tag-android"],"_links":{"self":[{"href":"http:\/\/www.tansoo.cn\/index.php?rest_route=\/wp\/v2\/posts\/778","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.tansoo.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.tansoo.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.tansoo.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.tansoo.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=778"}],"version-history":[{"count":0,"href":"http:\/\/www.tansoo.cn\/index.php?rest_route=\/wp\/v2\/posts\/778\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.tansoo.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=778"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.tansoo.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=778"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.tansoo.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=778"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}