Create a new project and modify the main file for the project production Activity_main.xml
<LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent" ><ListViewAndroid:id= "@+id/list_view"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent" ></ListView></LinearLayout>
Write the corresponding activity code
Public classMainactivityextendsActivity {Privatestring[] data = {"Apple", "Banana", "Orange", "Watermelon","Pear", "Grape", "Pineapple", "Strawberry", "Cherry", "Mango" }; @Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate); Setcontentview (R.layout.activity_main); Arrayadapter<String> adapter =NewArrayadapter<string>(mainactivity. This, Android. R.layout.simple_list_item_1, data); ListView ListView=(ListView) Findviewbyid (R.id.list_view); Listview.setadapter (adapter); }}
Simple usage of the ListView