Simple android studio Listview instance
// Layout <? Xml version = "1.0" encoding = "UTF-8"?> <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" android: paddingLeft = "@ dimen/users" android: paddingRight = "@ dimen/users" android: paddingTop = "@ dimen/activity_vertical_margin" android: paddingBottom = "@ dimen/activity_v Ertical_margin "> <ListView android: layout_width =" match_parent "android: layout_height =" match_parent "android: id =" @ android: id/list "/> </RelativeLayout> // code package com. example. test. testlistview; import android. app. listActivity; import android. OS. bundle; import android. view. view; import android. widget. arrayAdapter; import android. widget. listView; import android. widget. textView; import android. widget. toast; im Port java. util. arrayList; import java. util. list; public class ListViewArrayadapter extends ListActivity {@ Override protected void onCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState); setContentView (R. layout. activity_list_view_arrayadapter); List <String> ls = new ArrayList <String> (); ls. add ("test data 1"); ls. add ("Test Data 2"); ls. add ("test data 1"); ls. add ("Test Data 2"); ls. add ("test data 1"); ls. add ("Test Data 2 "); ls. add ("test data 1"); ls. add ("Test Data 2"); ls. add ("test data 1"); ls. add ("Test Data 2"); ls. add ("test data 1"); ls. add ("Test Data 2"); ArrayAdapter adapter = new ArrayAdapter (this, android. r. layout. simple_list_item_1, ls); setListAdapter (adapter); // This function is available only when ListActivity is inherited.} @ Override protected void onListItemClick (ListView l, View v, int position, long id) {String s = (TextView) v ). getText (). toString (); Toast. makeText (this, "prompt" + po Sition + s, Toast. LENGTH_LONG ). show (); super. onListItemClick (l, v, position, id) ;}// simple listview, the key is the adaptation of layout and data in ArrayAdapter. The style that comes with the android. R. layout. simple_list_item_1 system. You can change the layout style as required. List <String> ls = new ArrayList <String> () indicates the data to be displayed.