List in Android

List in Android

The display of elements in a list in Android is very common pattern in mobile applications. When the users want to see a list of items and can also scroll through them.

In android, ListView is a view which groups several items in the list in the manner we want and want to display them in vertical scrollable list. The list items are automatically inserted in list with the help of using an adapter that helps in pulls the content from a source as an array or from database.

Adapters:

An Adapter is a view which manages the data model and adapts it to the individual entries in the widget. An Adapter extends the BaseAdapter class to inherit the values methods of the BaseAdapter class.

Android provide several subclasses of adapter that are useful for retrieving different kinds of data and building views for an AdapterView.

android application development company

The common adapters which are used as follows:

  • ArrayAdapter
  • BaseAdapter,
  • CursorAdapter
  • SimpleCursorAdapter
  • spinnerAdapter
  • Wrapper adapter

We can also create listView by creating a single customView and then with the help of this we can create a number of items and images in list according to the need. Here we are creating listView with the help of customView.

Let’s get start by creating a project

  1. Create a new project by going to file then new android project.
  2. Once the project is created. Create an xml file to create a custom layout of our list and add the following code for a image on left hand side two textView and a button on right hand side.

android apps development company

Android application development company

Android application development company

3. Now creating a main XML file and add list in the following by adding this code inside a relative layout.

 Android application development company

4. We add the code in mainactivity.java to access the custom list in the listview

 Android application development company4.1

 

Android application development company

  1. Now create the Custom Array adapter class to use the adapter in the code

Android application development company

Android application development company

Android application development company

Android apps development company

6. Finally add the colors in colors class in resource to add the colors of button which you want. 

android apps development company

7. After adding all the code as describe above, run the app on emulator. Finally you get the following view or layout of the following applications.

 Android application development company

Also Read- Play Audio Video With AVFoundation

If you are, looking to Develop and design for your project then feel free to contact us at any time

  • Call Us- +91 9910781148, +1 8033353593
  • Email: company@tecorb.com
  • Skype- tecorb

“We maintain transparency with our customers. Our values and business ethics has given us repeated customers. We tend are proud to be a reliable outsourcing partner for many clients across the World.”

Published By – Akansha Sharma ( Android Developer )