How to implement simple ListView in android

How to implement simple ListView in android

How to implement simple ListView in Android

Here I am going to show you how to implement simple ListView in android. First of all, you need to know what is list view and how it works in android then we will move towards the implementation.

What is ListView :

List view is a list of items having the same view or you can say the presentation. In android, Adapter is used to hold the list item which then binds items to the listview. Adapter fetches the data from the data source like the array or from the cursor which stores the result of the database query. Now we will see the actual implementation of a list view.

Implement simple ListView in android :

To implement simple listview in android follow the below steps :

  1. Create the new project in Android Studio as File ->New-> New Project.
  2. Name your project whatever you want and rename MainActivity as SimpleListViewActivity then select Finish.
  3. We want data that will display in list view, here I am using an array as a data source. Create string array inside res -> values-> string.xml as below.

4. Create the layout for the single item of a list. res » layout » right click » Layout resource file » give a name listview_item.xml  then press OK.

5. Copy the below code to the listview_item.xml.

6. Now open SimpleListViewActivity from java package and copy the below text.

7. Finally, Open your AndroidManifest.xml from a manifest package and add make changes to your AndroidManifest file as below.

8. Now run your project you will see the output as shown below.

How to implement simple ListView in android

Simple ListView in Android

I hope this would have helped you. For any query you can comment below, I am always ready to help you.

Click to comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Most Popular

Buzzing your life from assorted Coding,tips and general life opinion. Made your life Buzz by BuzzMyCode articles, share with world.

What is Buzzmycode, we had started this website to give tech savy the new way of life by reading our fresh organic content on every technology and applications.

Copyright © 2017 SyncSaS. Theme by SyncSaS Themes, powered by BuzzMyCode.

To Top