SlideShare a Scribd company logo
Android
Lists, adapters and recycling
Bibliography
1. Wallace Jackson, Android Apps for Absolute
Beginners, Apress, 2017
2. Hello Views,
http://developer.android.com/guide/tutorials/vi
ews/index.html
3. Android Application Fundamentals,
http://developer.android.com/guide/topics/fun
damentals.html
2
Contents
• MVC
• Lists
– Model
– Adaptor
• List Elements
– Simple
– from XML
• ListActvity
• Optimization
– Recycling
– Tags
– Cache
• GridView
3
Model View Controller
• Pattern
• Splits
– UI
– Program
– Data storage
• Advantages
– Programing with components
– Easier to maintain
• Disadvantages
– May be slow
4
MVC Empirical
Database (Model)
Display (View) Program logic (Controller)
5
MVC Schematics
6
Specific Activities
• ListActivity
– Specially for a list
– May have other components
– List ID
• android:id=“@android:id/list”
• Special functions
– onListItemClick (…)
– setListAdapter (…)
7
Adapter
8
ListView
• A vertical container
– Similar with ScrollView
– Optimized for movement
• Identical components
– Each row
– Almost true ;)
• Adapter’s role
– Creates these components
• Events
– setOnItemClickListener (…)
– setOnItemLongClickListener (…)
9
Adapter
• Part of View
• Specifies the way of
display
– Adapts the data
– Modifies the View
10
ListView Adapter
• Predefined
– ArrayAdapter
• User defined
– Implementation of ListAdapter
– Extend BaseAdapter
11
Usage of ArrayAdapter (XML)
• Example
– Static list
12
Usage of ArrayAdapter (Java)
• Example
– Static List
13
Usage of ArrayAdapter (XML)
• Example
– Dynamic List
14
Usage of ArrayAdapter (Java)
15
A simple list
• ListView
– Contains a list
– android:id=“@android:id/list”
• Elements of the list
– android.R.layout.simple_list_item_1
• Static
– May use String[]
• Dynamic
– Use ArrayList<String>
16
The List with complex elements
• Elements
– Components
• EditView
• ImageView
• Container
• Adapter custom-made
– Implement ListAdapter
– Extend BaseAdapter
17
Extend BaseAdapter
• View getView (int position, View convertView,
ViewGroup list)
• int getCount ()
• Object getItem (int position)
• long getItemId (int position)
• int getViewTypeCount ()
• int getItemViewType (int position)
18
Extend BaseAdapter (XML)
19
Extend BaseAdapter (Java)
20
Extend BaseAdapter (Java)
21
Extend BaseAdapter (Java)
22
Extend BaseAdapter (Java)
23
Recycling
• Objects reusage
• Avoid object creation
– new is bad for memory!
• Use
– Buffers
– Lists
24
Optimisation
Inefficient!!!
25
Optimisation
Recycling
26
Different types of elements?
int getViewTypeCount ()
int getItemViewType (int position)
27
One more problem
Slow!!!
28
Tags (for View)
• void setTag (Object tag)
• Object getTag ()
29
Efficient using Tag
Utilizarea tag-ului
30
GridView
• Identical with ListView
– Extend BaseAdapater
31
The new RecyclerView
• A new way of building lists
– Uses several layouts
• Not just a LinearLayout
– The developer has to use recycling and tagging
• Extend RecyclerView.Adapter
– onCreateViewHolder()
• Inflate the view
– onBindViewHolder()
• Set the View’s data
– getItemCount()
32
Conclusions
• Lists
– Linear containers
– Contain components
• Including containers
• ListActivity
– Activity with special functions for list
• Adapter
– Formats the data from the model for the list
– Simple
– Custom made
– Recycling of elements
• Elements
– Described in XML
33
Keywords
• MVC
• Adaptor
• Classes
– ListActivity
– ListView
– GridView
– View
– ArrayAdapter
– BaseAdapter
– ArrayList
• Interfaces
– ListAdapter
• Recycling
• Tags
34
Questions
35

More Related Content

PPTX
MDAD 5 - Android - Lists, adapters and recycling
PPTX
MDAD 3 - Basics of UI Applications
PPTX
MDAD 4 - Android - Basics of UI Applications
PPTX
MDAD 2 - Introduction to the Android Framework
PDF
Scala ecosystem - Dublin Scala Meetup, Oct 2018
PDF
Scala Frameworks for Web Application 2016
PPTX
Digital Publishing with the OSCI Toolkit - Workshop MCN 2012
PPTX
Spider进化论
MDAD 5 - Android - Lists, adapters and recycling
MDAD 3 - Basics of UI Applications
MDAD 4 - Android - Basics of UI Applications
MDAD 2 - Introduction to the Android Framework
Scala ecosystem - Dublin Scala Meetup, Oct 2018
Scala Frameworks for Web Application 2016
Digital Publishing with the OSCI Toolkit - Workshop MCN 2012
Spider进化论

Similar to MDAD 4 - Lists, adapters and recycling (20)

PDF
Lab2-android
PDF
Day 8: Dealing with Lists and ListViews
PDF
List Views
PPTX
Introduction to Listview in Android
PPTX
chp 4 UI component hdjdjdduudfinalt.pptx
PPTX
Day 5 android app code advancement
PPTX
ListView RecyclerView.pptx
PDF
Day 8: Dealing with Lists and ListViews
PPT
Lecture Slides for List Views [Android ]
PPT
Hello Android
PDF
Android UI Development: Tips, Tricks, and Techniques
PDF
Android UI Tips, Tricks and Techniques
PDF
Adapter and cache technique
PDF
Android - Build User Interface
PPT
Android ListView and Custom ListView
DOCX
Android list view tutorial by Javatechig
PPTX
Android bootcamp 2013 Lists & Adapter
PPTX
Android Chapter 4 part2 Types of View and View group
PPTX
Android Training (AdapterView & Adapter)
Lab2-android
Day 8: Dealing with Lists and ListViews
List Views
Introduction to Listview in Android
chp 4 UI component hdjdjdduudfinalt.pptx
Day 5 android app code advancement
ListView RecyclerView.pptx
Day 8: Dealing with Lists and ListViews
Lecture Slides for List Views [Android ]
Hello Android
Android UI Development: Tips, Tricks, and Techniques
Android UI Tips, Tricks and Techniques
Adapter and cache technique
Android - Build User Interface
Android ListView and Custom ListView
Android list view tutorial by Javatechig
Android bootcamp 2013 Lists & Adapter
Android Chapter 4 part2 Types of View and View group
Android Training (AdapterView & Adapter)
Ad

More from Alexandru Radovici (20)

PPTX
SdE2 - Pilot Tock
PPTX
SdE2 - Systèmes embarquées
PPTX
SdE2 - Planification, IPC
PPTX
ALF1 - Introduction
PPTX
SdE2 - Introduction
PPTX
MDAD 6 - AIDL and Services
PPTX
MDAD 5 - Threads
PPTX
MDAD 1 - Hardware
PPTX
MDAD 0 - Introduction
PPTX
SdE 11 - Reseau
PPTX
SdE 10 - Threads
PPTX
SdE 8 - Synchronisation de execution
PPTX
SdE 8 - Memoire Virtuelle
PPTX
SdE 7 - Gestion de la Mémoire
PPTX
SdE 6 - Planification
PPTX
SdE 5 - Planification
PPTX
ALF 6 - Parser
PPTX
ALF 5 - Parser
PPTX
ALF 4 - Grammaires
PPTX
ALF 3 - Expressions régulières et Lexer
SdE2 - Pilot Tock
SdE2 - Systèmes embarquées
SdE2 - Planification, IPC
ALF1 - Introduction
SdE2 - Introduction
MDAD 6 - AIDL and Services
MDAD 5 - Threads
MDAD 1 - Hardware
MDAD 0 - Introduction
SdE 11 - Reseau
SdE 10 - Threads
SdE 8 - Synchronisation de execution
SdE 8 - Memoire Virtuelle
SdE 7 - Gestion de la Mémoire
SdE 6 - Planification
SdE 5 - Planification
ALF 6 - Parser
ALF 5 - Parser
ALF 4 - Grammaires
ALF 3 - Expressions régulières et Lexer
Ad

Recently uploaded (20)

DOCX
Cambridge-Practice-Tests-for-IELTS-12.docx
PDF
Τίμαιος είναι φιλοσοφικός διάλογος του Πλάτωνα
PDF
AI-driven educational solutions for real-life interventions in the Philippine...
PDF
MBA _Common_ 2nd year Syllabus _2021-22_.pdf
PDF
FOISHS ANNUAL IMPLEMENTATION PLAN 2025.pdf
PDF
Weekly quiz Compilation Jan -July 25.pdf
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PPTX
20th Century Theater, Methods, History.pptx
PPTX
Computer Architecture Input Output Memory.pptx
PDF
My India Quiz Book_20210205121199924.pdf
PDF
Empowerment Technology for Senior High School Guide
PPTX
Unit 4 Computer Architecture Multicore Processor.pptx
PDF
FORM 1 BIOLOGY MIND MAPS and their schemes
PDF
Paper A Mock Exam 9_ Attempt review.pdf.
PDF
Vision Prelims GS PYQ Analysis 2011-2022 www.upscpdf.com.pdf
PDF
احياء السادس العلمي - الفصل الثالث (التكاثر) منهج متميزين/كلية بغداد/موهوبين
PDF
advance database management system book.pdf
PDF
Hazard Identification & Risk Assessment .pdf
PPTX
Virtual and Augmented Reality in Current Scenario
PDF
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
Cambridge-Practice-Tests-for-IELTS-12.docx
Τίμαιος είναι φιλοσοφικός διάλογος του Πλάτωνα
AI-driven educational solutions for real-life interventions in the Philippine...
MBA _Common_ 2nd year Syllabus _2021-22_.pdf
FOISHS ANNUAL IMPLEMENTATION PLAN 2025.pdf
Weekly quiz Compilation Jan -July 25.pdf
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
20th Century Theater, Methods, History.pptx
Computer Architecture Input Output Memory.pptx
My India Quiz Book_20210205121199924.pdf
Empowerment Technology for Senior High School Guide
Unit 4 Computer Architecture Multicore Processor.pptx
FORM 1 BIOLOGY MIND MAPS and their schemes
Paper A Mock Exam 9_ Attempt review.pdf.
Vision Prelims GS PYQ Analysis 2011-2022 www.upscpdf.com.pdf
احياء السادس العلمي - الفصل الثالث (التكاثر) منهج متميزين/كلية بغداد/موهوبين
advance database management system book.pdf
Hazard Identification & Risk Assessment .pdf
Virtual and Augmented Reality in Current Scenario
ChatGPT for Dummies - Pam Baker Ccesa007.pdf

MDAD 4 - Lists, adapters and recycling