Android tutorial - Listview in android | Android ListView example - android app development - android studio - android development tutorial
Learn android - android tutorial - Listview in android - android examples - android programs
Android ListView:
- Android ListView is a view which groups several items and display them in vertical scrollable list.
- The list items are automatically inserted to the list using an Adapter that pulls content from a source such as an array or database.
- In Android, ListView let you arranges components in a vertical scrollable list. In this tutorial, we will show you 2 ListView examples :
- Normal way to display components in ListView.
- Custom array adapter to customize the item display in ListView.
- P.S This project is developed in Eclipse 3.7, and tested with Android 2.3.3.
1. Normal ListView example: 1. Normal ListView example:
- In this example, we show you how to display a list of fruit name via ListView, it should be easy and self-explanatory.
1.1 Android Layout file
- File : res/layout/list_fruit.xml
1.2 ListView
1.3 Demo - android emulator - android tutorial
2. Custom ArrayAdapter example:
- In this example, we show you how to create 4 items in the ListView, and use a custom “ArrayAdapter” to display different images base on the “item name” in the list.
2.1 Images
- Get 4 images for Demo - android emulator - android tutorialnstration.
2.2 Android Layout file
- File : res/layout/list_mobile.xml
2.3 Custom ArrayAdapter
- Create a class extends ArrayAdapter and customize the item display in the getView() method.
2.4 ListView
- ListView, but use above custom adapter to display the list.