Download presentation
Presentation is loading. Please wait.
1
ListView ? BaseAdapter ?
2
Steps to create a ListView
Image Title Content Image Title Content Prepare data Sources[Images + Titles + Description] Define appearance of a single row in xml Create a Custom adapter that maps data from the data source to single row Set Adapter to the ListView Decide what happens when the user clicks on an item. Image Title Content Image Title Content Image Title Content Image Title Content ListView
3
Step 1: Prepare the data sources
Class ContactModel{ String image; String title; String content; // override getter setter Methods } ArrayList<ContactModel> contact =new ArrayList<ContactModel>(); Create Model or Class to contain all the data of adapter view. Make ArrayList of Object type (Class or Model of first step). Set values to ArrayList. Pass data in new Object Adapter Class through Constructor. ContactAdapter contactAdapter = new ContactAdapter(context,contact)
4
Step 2: Define the appearance of a Single row
ImageView TextView 2 TextView 2 Single Layout Xml
5
Step 3: Create Custom Adapter
Create class that extends BaseAdapter Implement all the methods Use the getView method to map the data sources to the Views of a single row.
6
Step 4: Set Adapter to ListView
listView.setAdapter(contactAdapter);
7
Questions ?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.