{"rsdb":{"rid":"410203","subhead":"","postdate":"0","aid":"283339","fid":"98","uid":"1","topic":"1","content":"
\n

\u4e00\u3001ListView<\/p> \n

\u8be5\u7ec4\u4ef6\u662fandroid\u4e2d\u6700\u5e38\u7528\u7684\u4e00\u4e2aUI\u7ec4\u4ef6\uff0c\u7528\u4e8e\u5b9e\u73b0\u5728\u5c4f\u5e55\u4e0a\u663e\u793a?\u591a\u4e2a\u5185\u5bb9\uff0c\u4ee5\u4fbf\u4e8e\u6211\u4eec\u7528\u624b\u6307\u6765\u56de\u7ffb\u8f6c\u3002<\/p> \n

\u5148\u5728layout\u4e2d\u8fdb\u884c\u5e03\u5c40\u6211\u4eec\u7684\u7ec4\u4ef6<\/p> \n

\n
 \n\n<<\/span>LinearLayout <\/span>xmlns:android<\/span>="http:\/\/schemas.android.com\/apk\/res\/android"<\/span>\n\n    android:layout_width<\/span>="match_parent"<\/span>\n\n    android:layout_height<\/span>="match_parent"<\/span> ><\/span>\n\n \n\n    <<\/span>ListView\n\n        <\/span>android:id<\/span>="@+id\/list_view"<\/span>\n\n        android:layout_width<\/span>="match_parent"<\/span>\n\n        android:layout_height<\/span>="match_parent"<\/span> ><\/span>\n\n         \n\n    <\/<\/span>ListView<\/span>><\/span>\n\n<\/<\/span>LinearLayout<\/span>><\/span><\/pre> \n <\/div> \n 

 <\/p> \n

?<\/p> \n

\u5bf9\u8be5\u7ec4\u4ef6\u6ce8\u518c\u4e00\u4e2alist_view\u7684ID\uff08\u8fd9\u4e2aR\u4e2d\u7684\u8bed\u53e5\u662f\u8fd0\u884c\u65f6\u4f1a\u81ea\u52a8\u751f\u6210\u7684\uff09\uff0c\u53ef\u5728\u8fd9\u91cc\u770b\u5230<\/p> \n

 <\/p> \n

\"\"<\/p> \n

\u8fd9\u6837\u8fd9\u4e2a\u7ec4\u4ef6\u5c31\u5b9a\u4e49\u597d\u4e86\uff0c\u7136\u540e\u5728\u6d3b\u52a8\u7684\u6e90\u7801\u4e2d\u8fdb\u884c\u6ce8\u518c<\/p> \n

 <\/p> \n

\n
package<\/span> com.example.listviewtest;\n\n?\n\n<\/span>import<\/span> android.app.Activity;\n\n<\/span>import<\/span> android.os.Bundle;\n\n<\/span>import<\/span> android.view.Menu;\n\n<\/span>import<\/span> android.view.MenuItem;\n\n<\/span>import<\/span> android.widget.ArrayAdapter;\n\n<\/span>import<\/span> android.widget.ListView;\n\n<\/span>\/\/<\/span>import java<\/a>.lang.ArrayAdapter;<\/span>\n\n?\n\n<\/span>public<\/span> class<\/span> MainActivity extends<\/span> Activity {\n\n  <\/span>private<\/span> String[] data = {"Apple","Banana","Orange","Watermelon","Pear","Grape","Pineapple","Strawberry","Cherry"};\n\n \n\n  @Override\n\n  <\/span>protected<\/span> void<\/span> onCreate(Bundle savedInstanceState) {\n\n    <\/span>super<\/span>.onCreate(savedInstanceState);\n\n    setContentView(R.layout.activity_main);\n\n    ArrayAdapter<\/span><String> adapter = new<\/span> ArrayAdapter<String>(\n\n        MainActivity.<\/span>this<\/span>,android.R.layout.simple_list_item_1,data);\n\n    ListView listView <\/span>= (ListView) findViewById(R.id.list_view);\n\n    listView.setAdapter(adapter);\n\n  }\n\n}<\/span><\/pre> \n <\/div> \n 

 <\/p> \n

\u53ef\u4ee5\u770b\u51fa\u8fd9\u91cc\u4f7f\u7528\u4e86\u4e00\u4e2aAndroid\u81ea\u5e26\u9002\u914d\u5668\u7c7bArrayAdapter\uff0c\u4f7f\u7528\u6cdb\u578bString\u7684\u5b9e\u4f8b\u521b\u5efa\uff0c\u7136\u540e\u4f20\u5165\u53c2\u6570\uff0c\u5206\u522b\u4e3a\u4e0a\u4e0b\u6587\u5b9e\u4f8b\uff0candroid\u81ea\u5e26\u7684\u4e00\u4e2alist_item_1\u7684\u5185\u90e8\u5e03\u5c40\u6587\u4ef6\uff0c\u91cc\u9762\u53ea\u6709\u4e00\u4e2aTextView,\u53ef\u7528\u4e8e\u663e\u793a\u4e00\u6bb5\u7b80\u5355\u7684\u6587\u672c\uff1b\u6700\u540e\u4e00\u4e2a\u53c2\u6570\u5c31\u662f\u6211\u4eec\u4f20\u5165\u7684\u6570\u636e?\u3002<\/p> \n

\u521b\u5efa\u4e00\u4e2aListView\u7684\u5b9e\u4f8b\uff0c\u5e76\u4e14\u627e\u5230\u8fd9\u4e2a?R\u6587\u4ef6\u7684listView\u5730\u5740\u3002\u6700\u540e\u8c03\u7528setAdapter()\u65b9\u6cd5\uff0c\u5373\u4e3a\u8bbe\u7f6e\u5b8c\u6bd5\u3002<\/p> \n

 <\/p> \n

\"\"<\/p> \n

\u4e8c\u3001\u6e90\u7801\uff1a<\/p> \n

1.\u9879\u76ee\u5730\u5740<\/p> \n

https:\/\/github.com\/ruigege66\/Android\/tree\/master\/ListViewTest<\/p> \n

2.CSDN\uff1ahttps:\/\/blog.csdn.net\/weixin_44630050<\/p> \n

3.\u535a\u5ba2\u56ed\uff1ahttps:\/\/www.cnblogs.com\/ruigege0000\/<\/p> \n

4.\u6b22\u8fce\u5173\u6ce8\u5fae\u4fe1\u516c\u4f17\u53f7\uff1a\u5085\u91cc\u53f6\u53d8\u6362\uff0c\u4e2a\u4eba\u516c\u4f17\u53f7\uff0c\u4ec5\u7528\u4e8e\u5b66\u4e60\u4ea4\u6d41\uff0c\u540e\u53f0\u56de\u590d\u201d\u793c\u5305\u201c\uff0c\u83b7\u53d6\u5927\u6570\u636e\u5b66\u4e60\u8d44\u6599<\/p> \n

 \"\"<\/p> \n

 <\/p> \n<\/div>","orderid":"0","title":"Android\u8fde\u8f7d2-ListView\u8bf4\u660e","smalltitle":"","mid":"0","fname":"Android","special_id":"0","bak_id":"0","info":"0","hits":"37","pages":"1","comments":"0","posttime":"2020-04-04 06:16:55","list":"1585952215","username":"admin","author":"","copyfrom":"","copyfromurl":"","titlecolor":"","fonttype":"0","titleicon":"0","picurl":"https:\/\/www.cppentry.com\/upload_files\/","ispic":"0","yz":"1","yzer":"","yztime":"0","levels":"0","levelstime":"0","keywords":"Android<\/A> \u8fde\u8f7d<\/A> 2-ListView<\/A> \u8bf4\u660e<\/A>","jumpurl":"","iframeurl":"","style":"","template":"a:3:{s:4:\"head\";s:0:\"\";s:4:\"foot\";s:0:\"\";s:8:\"bencandy\";s:0:\"\";}","target":"0","ip":"14.17.22.33","lastfid":"0","money":"0","buyuser":"","passwd":"","allowdown":"","allowview":"","editer":"","edittime":"0","begintime":"0","endtime":"0","description":"Android\u8fde\u8f7d2-ListView\u8bf4\u660e","lastview":"1591324592","digg_num":"0","digg_time":"0","forbidcomment":"0","ifvote":"0","heart":"","htmlname":"","city_id":"0"},"page":"1"}