Android ListView is a view which contains the group of items and displays in a scrollable list. ListView is implemented by importing android.widget.ListView class. ListView is a default scrollable which does not use other scroll view.
ListView uses Adapter classes which add the content from data source (such as string array, array, database etc) to ListView. Adapter bridges data between an AdapterViews and other Views (ListView, ScrollView etc).
Example of ListView
Let's implement a simple listview example.
Structure of listview project
First we need to drag and drop ListView component from palette to activity_main.xml file.
Create an additional mylist.xml file in layout folder which contains view components displayed in listview.
Now place the list of data in strings.xml file by creating string-array.
In java class we need to add adapter to listview using setAdapter() method of listview.
JavaTpoint offers too many high quality services. Mail us on [email protected], to get more information about given services.
JavaTpoint offers college campus training on Core Java, Advance Java, .Net, Android, Hadoop, PHP, Web Technology and Python. Please mail your requirement at [email protected]
Duration: 1 week to 2 week