A listview is used to display a list of values coming from different types of sources such as databases, string arrays etc., its a dynamic way of displaying the values when don’t know the exact number of values.

In this custom listview android tutorial i will show a list of colors and a toast displayed when clicked on the listview with selected color

Here in this android studio listview example i am showing you the basic listview using a custom listview adapter.

 

And before going any further i would recommend you to use android recyclerview which has much efficiency than the listview for more info please visit

recyclerview android tutorial

http://www.androidcoding.in/recyclerview/

 

 

Populating listview based on String [] list values.

 

MainActivity.java

 

A String array is used to populate the listview  as

 

And using the ArrayAdapter

 

 

Add a listview in layout and also a textview.

activity_main.xml

Adding a listview to the xml file as

 

 

AndroidManifest.xml

 

Output

list1

list2

If any query or for full coding please comment in the below section.

Like and share the tutorial if you like it.

Show Buttons
Hide Buttons
Read previous post:
Android Tutorial on Simple Login

Close