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.
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.
The common adapters which are used as follows:
- 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
- Create a new project by going to file then new android project.
- 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.
3. Now creating a main XML file and add list in the following by adding this code inside a relative layout.
4. We add the code in mainactivity.java to access the custom list in the listview
- Now create the Custom Array adapter class to use the adapter in the code
6. Finally add the colors in colors class in resource to add the colors of button which you want.
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.
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: firstname.lastname@example.org
- 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 )