1、配置布局文件:
<?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);
3、显示效果如下: