<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" >
<ListView
android:id="@+id/list_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
</ListView>
</RelativeLayout>
package com.example.listviewtest;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
public class ListviewtestActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.listviewtest);
ListView lv =(ListView)findViewById(R.id.list_view);
String[] data ={"apple","banana","watermelon","pear","peach","grape","mango","strawberry","tomato","pineapple","cherry","tea","coin","hha"};
ArrayAdapter<String> adapter = new ArrayAdapter<String>(ListviewtestActivity.this,android.R.layout.simple_list_item_1,data);
lv.setAdapter(adapter);
}
}
![](https://images2015.cnblogs.com/blog/899124/201602/899124-20160229211455580-444107998.png)