Android中ListView与ArrayAdapter配合使用,
投稿于 被查看 41275 次 评论:279
Android中ListView与ArrayAdapter配合使用,
<无详细内容>1.main.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:Android="http://schemas.android.com/apk/res/android" Android:orientation="vertical" android:layout_width="fill_parent" Android:layout_height="fill_parent"> <!-- 注意这里的Android:id是使用内置的--> <ListView Android:id="@android:id/list " Android:layout_width="fill_parent" Android:layout_height="wrap_content"></ListView> </LinearLayout>
2.[Java]代码
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); String[]items ={"aaa","bbbb","cccc"}; ArrayAdapter arrayAdapter = new ArrayAdapter(this,Android.R.layout.simple_list_item_1 ,items); setListAdapter(arrayAdapter); }
用户评论