SlideShare a Scribd company logo
ListView and Adapters Software Development for Portable Devices  BITS Pilani Goa Campus Sem I 2011-12
CS C314 Software Development For Portable Devices Foundation of :
Problem?? Performance 10,000 entries in a list! Less than 10% shown but fetched completely
Solution?? Populate on Demand Google image search Recycle views to reduce object churn
Android – ListView Its a view capable of displaying  scrollable list of items It only creates views (widget) if needed It recycles views, e.g. if a row is not displayed anymore it will be recycled and only its content will change.
The FLOW diagram
Adapters extends "BaseAdapter“ "ArrayAdapter" can handle data based on Arrays "SimpleCursorAdapter" handle  database  related data Your own "CustomAdapter"
Android - ListActivity If Activity is primarily showing a list you should extend the activity "ListActivity“ It simplifies the handling of a "ListView“ Set Listadapter in the onCreate(), via the method setListAdapter(). Register the click by onListItemClick(ListView l, View v, int position, long id) CS C314 Software Development For Portable Devices
onListItemClick Parameters l : The ListView where the click happened v : The view that was clicked within the ListView position : The position of the view in the list id : The row id of the item that was clicked CS C314 Software Development For Portable Devices
  ListActivity with ArrayAdapter and Android standard layout See the code FirstExample CS C314 Software Development For Portable Devices
   ListActivity with own layout See the code SecondExample Define the layout in xml for each row Define our own arrayAdapter and using Id telling adapter which UI element is the text CS C314 Software Development For Portable Devices
   ListActivity with flexible layout See the code ThirdExample Override getView(). Performance is not optimized.. Think why? CS C314 Software Development For Portable Devices
   Performance Issues Creating Java objects for each row is time and memory consumption.  findViewById() is a expensive operation Android recycles rows (views) which are not displayed anymore. CS C314 Software Development For Portable Devices
   Optimized Way Using existing rows saves memory and CPU consumption . convertView -  The old view to reuse avoid doing findViewById() if not necessary  ViewHolder pattern  175% faster then the older procedure CS C314 Software Development For Portable Devices
   ViewHolder The ViewHolder stores a reference to the required views in a row ViewHolder is then attached to the row via the method setTag() row is recycled we can get the ViewHolder via getTag() method much faster then the repetitive call of findViewById() CS C314 Software Development For Portable Devices
   Optimized way See the code CS C314 Software Development For Portable Devices
Your task Your task is to implement the View holder pattern in the Add food class CS C314 Software Development For Portable Devices
   Interacting rows Your row layout can also contain views which interact with the underlying data model. Example : Checkboxes CS C314 Software Development For Portable Devices
Try Out LongClickListeners Single Vs Multiple selection Header and Footers CS C314 Software Development For Portable Devices
References Spinner tutorial :  http://developer.android.com/resources/tutorials/views/hello-spinner.html ArrayAdapter: http://developer.android.com/resources/tutorials/views/hello-spinner.html CS C314 Software Development For Portable Devices

More Related Content

DOCX
Android list view tutorial by Javatechig
PPTX
Android Training (AdapterView & Adapter)
PPTX
Introduction to Listview in Android
PPTX
ListView and Custom ListView on Android Development [Thai]
PDF
Android ui adapter
ODP
Android App Development - 11 Lists, grids, adapters, dialogs and toasts
PDF
List Views
Android list view tutorial by Javatechig
Android Training (AdapterView & Adapter)
Introduction to Listview in Android
ListView and Custom ListView on Android Development [Thai]
Android ui adapter
Android App Development - 11 Lists, grids, adapters, dialogs and toasts
List Views

What's hot (19)

PPT
Android Ui
PDF
Has Many And Belongs To Many
PPTX
List adapter with multiple objects
PDF
Day 8: Dealing with Lists and ListViews
PPTX
Create an android app for database creation using.pptx
DOCX
Creating EPiServer Usage Reports
PPT
Android UI
ODP
Android App Development - 04 Views and layouts
PPTX
Android Programming.pptx
PPT
AutocompleteTextView And MultiAutoCompleteTextView
PPTX
Android Layout.pptx
PPTX
Android Layout
PDF
Basic Android Layout
PDF
ASP.net Image Slideshow
PDF
[Android] Using Selection Widgets
PDF
Hilt Annotations
DOCX
Animal Project
PDF
Lab2-android
PDF
Ember.js Self Defining Apps
Android Ui
Has Many And Belongs To Many
List adapter with multiple objects
Day 8: Dealing with Lists and ListViews
Create an android app for database creation using.pptx
Creating EPiServer Usage Reports
Android UI
Android App Development - 04 Views and layouts
Android Programming.pptx
AutocompleteTextView And MultiAutoCompleteTextView
Android Layout.pptx
Android Layout
Basic Android Layout
ASP.net Image Slideshow
[Android] Using Selection Widgets
Hilt Annotations
Animal Project
Lab2-android
Ember.js Self Defining Apps
Ad

Viewers also liked (18)

PDF
Android development - ListView & Adapter
PDF
Android tutorial points
PPTX
Android Tutorials : Basic widgets
PDF
Adapter & ListView & ExpandalbeListView
PDF
Layouts in android
PDF
Developing Applications for Android - Lecture#1
PDF
Adapter and cache technique
PDF
Android sync adapter
PPTX
Android ui part 2
PPTX
Android Application Fundamentals.
PPTX
Android Session 6 - UI Part 1
PPT
Post-PC: Geolocation & Maps in the Android Ecosystem
PPTX
Android 5.0, Lollipop
PDF
Android ui layout
PDF
Android life cycle
PPTX
Basic android-ppt
PPT
Android User Interface: Basic Form Widgets
PPTX
Google ART (Android RunTime)
Android development - ListView & Adapter
Android tutorial points
Android Tutorials : Basic widgets
Adapter & ListView & ExpandalbeListView
Layouts in android
Developing Applications for Android - Lecture#1
Adapter and cache technique
Android sync adapter
Android ui part 2
Android Application Fundamentals.
Android Session 6 - UI Part 1
Post-PC: Geolocation & Maps in the Android Ecosystem
Android 5.0, Lollipop
Android ui layout
Android life cycle
Basic android-ppt
Android User Interface: Basic Form Widgets
Google ART (Android RunTime)
Ad

Similar to Lecture Slides for List Views [Android ] (20)

PPTX
MDAD 4 - Lists, adapters and recycling
PPTX
MDAD 5 - Android - Lists, adapters and recycling
PPT
Hello Android
PDF
HIT3328 - Chapter03 - Simple Interactive Apps
PDF
Day 8: Dealing with Lists and ListViews
PDF
HIT3328 - Chapter0601 - Menus and Lists
PPTX
Day 5 android app code advancement
PDF
Android UI Tips, Tricks and Techniques
PDF
Android UI Development: Tips, Tricks, and Techniques
PPTX
Adapter and adapter views that are used in android
PPTX
Android Chapter 4 part2 Types of View and View group
PPTX
Android layouts course-in-mumbai
PDF
Workshop 04 android-development
PDF
EESTEC Android Workshop 2
PPTX
Android layouts course-in-mumbai
PDF
Android activities & views
PPTX
DevFest Sul 2014 - Android 4 lazy iOS Devs
PDF
Android - Build User Interface
PPTX
Building your first android app using xamarin (Gill Cleeren)
PDF
Dinosaurs and Androids: The Listview Evolution
MDAD 4 - Lists, adapters and recycling
MDAD 5 - Android - Lists, adapters and recycling
Hello Android
HIT3328 - Chapter03 - Simple Interactive Apps
Day 8: Dealing with Lists and ListViews
HIT3328 - Chapter0601 - Menus and Lists
Day 5 android app code advancement
Android UI Tips, Tricks and Techniques
Android UI Development: Tips, Tricks, and Techniques
Adapter and adapter views that are used in android
Android Chapter 4 part2 Types of View and View group
Android layouts course-in-mumbai
Workshop 04 android-development
EESTEC Android Workshop 2
Android layouts course-in-mumbai
Android activities & views
DevFest Sul 2014 - Android 4 lazy iOS Devs
Android - Build User Interface
Building your first android app using xamarin (Gill Cleeren)
Dinosaurs and Androids: The Listview Evolution

Recently uploaded (20)

PDF
Electronic commerce courselecture one. Pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
cuic standard and advanced reporting.pdf
PDF
Encapsulation theory and applications.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PPTX
Machine Learning_overview_presentation.pptx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
Cloud computing and distributed systems.
PDF
Machine learning based COVID-19 study performance prediction
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
A Presentation on Artificial Intelligence
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Electronic commerce courselecture one. Pdf
Review of recent advances in non-invasive hemoglobin estimation
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Mobile App Security Testing_ A Comprehensive Guide.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Unlocking AI with Model Context Protocol (MCP)
cuic standard and advanced reporting.pdf
Encapsulation theory and applications.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Diabetes mellitus diagnosis method based random forest with bat algorithm
NewMind AI Weekly Chronicles - August'25-Week II
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Machine Learning_overview_presentation.pptx
Building Integrated photovoltaic BIPV_UPV.pdf
Cloud computing and distributed systems.
Machine learning based COVID-19 study performance prediction
The AUB Centre for AI in Media Proposal.docx
A Presentation on Artificial Intelligence
gpt5_lecture_notes_comprehensive_20250812015547.pdf

Lecture Slides for List Views [Android ]

  • 1. ListView and Adapters Software Development for Portable Devices BITS Pilani Goa Campus Sem I 2011-12
  • 2. CS C314 Software Development For Portable Devices Foundation of :
  • 3. Problem?? Performance 10,000 entries in a list! Less than 10% shown but fetched completely
  • 4. Solution?? Populate on Demand Google image search Recycle views to reduce object churn
  • 5. Android – ListView Its a view capable of displaying scrollable list of items It only creates views (widget) if needed It recycles views, e.g. if a row is not displayed anymore it will be recycled and only its content will change.
  • 7. Adapters extends "BaseAdapter“ "ArrayAdapter" can handle data based on Arrays "SimpleCursorAdapter" handle database related data Your own "CustomAdapter"
  • 8. Android - ListActivity If Activity is primarily showing a list you should extend the activity "ListActivity“ It simplifies the handling of a "ListView“ Set Listadapter in the onCreate(), via the method setListAdapter(). Register the click by onListItemClick(ListView l, View v, int position, long id) CS C314 Software Development For Portable Devices
  • 9. onListItemClick Parameters l : The ListView where the click happened v : The view that was clicked within the ListView position : The position of the view in the list id : The row id of the item that was clicked CS C314 Software Development For Portable Devices
  • 10.   ListActivity with ArrayAdapter and Android standard layout See the code FirstExample CS C314 Software Development For Portable Devices
  • 11.   ListActivity with own layout See the code SecondExample Define the layout in xml for each row Define our own arrayAdapter and using Id telling adapter which UI element is the text CS C314 Software Development For Portable Devices
  • 12.   ListActivity with flexible layout See the code ThirdExample Override getView(). Performance is not optimized.. Think why? CS C314 Software Development For Portable Devices
  • 13.   Performance Issues Creating Java objects for each row is time and memory consumption. findViewById() is a expensive operation Android recycles rows (views) which are not displayed anymore. CS C314 Software Development For Portable Devices
  • 14.   Optimized Way Using existing rows saves memory and CPU consumption . convertView - The old view to reuse avoid doing findViewById() if not necessary ViewHolder pattern 175% faster then the older procedure CS C314 Software Development For Portable Devices
  • 15.   ViewHolder The ViewHolder stores a reference to the required views in a row ViewHolder is then attached to the row via the method setTag() row is recycled we can get the ViewHolder via getTag() method much faster then the repetitive call of findViewById() CS C314 Software Development For Portable Devices
  • 16.   Optimized way See the code CS C314 Software Development For Portable Devices
  • 17. Your task Your task is to implement the View holder pattern in the Add food class CS C314 Software Development For Portable Devices
  • 18.   Interacting rows Your row layout can also contain views which interact with the underlying data model. Example : Checkboxes CS C314 Software Development For Portable Devices
  • 19. Try Out LongClickListeners Single Vs Multiple selection Header and Footers CS C314 Software Development For Portable Devices
  • 20. References Spinner tutorial : http://developer.android.com/resources/tutorials/views/hello-spinner.html ArrayAdapter: http://developer.android.com/resources/tutorials/views/hello-spinner.html CS C314 Software Development For Portable Devices

Editor's Notes

  • #10: position is the clicked element's position in your Adapter (so you can doadapter.getItem(position) ) row id is the id that corresponds to that element, what your Adapter returns in the getItemId()method.