2. GridView
GridView is a view group that display items in two dimensional scrolling grid
(rows and columns).
Items are inserted into this grid layout from a database or from an array.
The ListView and GridView are subclasses of AdapterView and they can be
populated by binding them to an Adapter, which retrieves data from an external
source and creates a View that represents each data entry.
flutterjunction.com
3. Key Methods of GridView
flutterjunction.com
setAdapter(Adapter adapter)
Binds the data source (like an ArrayAdapter or custom adapter) to the
GridView.
gridView.setAdapter(adapter)
setNumColumns(int numColumns)
Sets the number of columns in the GridView.
gridView.setNumColumns(3);
4. Key Methods of GridView
flutterjunction.com
setOnItemClickListener(OnItemClickListener listener)
Handles item click events in the GridView.
gridView.setOnItemClickListener(listener);
getAdapter()
Returns the adapter currently associated with the GridView.
Adapter adapter = gridView.getAdapter();
5. Key Methods of GridView
flutterjunction.com
getSelectedItem()
Returns the item that is currently selected.
Object item = gridView.getSelectedItem();
7. GridView
flutterjunction.com
Features
Flexible Grid Layout:
GridView provides a structured grid layout that allows developers to organize
data into rows and columns. The number of columns can be dynamically
adjusted.
Automatic Data Binding:
With the help of adapters (like ArrayAdapter, BaseAdapter, or custom adapters),
GridView automatically binds and displays data from various sources (arrays,
lists, databases, etc.).
8. GridView
flutterjunction.com
Features
Customizable Grid Items
Each cell in the grid can be customized using custom layouts, allowing for rich
content such as images, text, and interactive UI components.
Scrollable Grid:
GridView is inherently scrollable both vertically and horizontally, making it ideal
for large data sets that require scrolling.
9. GridView
flutterjunction.com
Features
Efficient Item Reuse
GridView efficiently reuses item views with the ViewHolder pattern, improving
performance and memory management when displaying large amounts of data.
Responsive Layout Control
Developers can control spacing between grid items, padding, alignment, and the
number of columns to make the grid adaptive across various screen sizes and
orientations.
11. RecyclerView
flutterjunction.com
RecyclerView is an advanced, flexible version of ListView and GridView, used to
efficiently display large datasets by recycling item views.
Why Use RecyclerView?
More flexible compared to ListView and GridView.
Supports different layout managers (Linear, Grid, Staggered).
Efficient memory usage with view recycling.
12. Components of RecyclerView
flutterjunction.com
RecyclerView:
The view that contains and displays a list of items.
LayoutManager:
Manages how items are arranged. Types include:
LinearLayoutManager (vertical/horizontal list)
GridLayoutManager (grid format)
StaggeredGridLayoutManager (grid with uneven rows/columns)
14. Methods in RecyclerView
flutterjunction.com
setLayoutManager(LayoutManager layoutManager)
Sets the layout manager (Linear, Grid, etc.) for arranging items.
setAdapter(Adapter adapter)
Binds the adapter to RecyclerView to manage and display data.
onCreateViewHolder(ViewGroup parent, int viewType)
Inflates the item layout and returns a new ViewHolder instance.
16. RecyclerView
flutterjunction.com
Additional Uses of RecyclerView
Efficient item recycling with the ViewHolder pattern.
Supports multiple layout managers.
Built-in animations for item changes (add, remove, move).
Easy implementation of complex lists (grids, staggered layouts).
More control over item layout, interaction, and decoration.
17. RecyclerView
flutterjunction.com
When to Use RecyclerView?
Scrollable Lists: Chat apps, social feeds.
Grids: Photo galleries, e-commerce product listings.
Staggered Grids: Pinterest-style layouts.
Complex Lists: Custom, interactive lists with varied item types.
19. Introduction to SQLite
flutterjunction.com
It is an open-source database provided in Android.
Lightweight, embedded database engine. So, there is no need to perform any
database setup or administration task.
Local storage solution for Android applications.
Stores data in tables with rows and columns.
The SQLite database is lazily initialized. This means that it isn't actually created
until it's first accessed through a call to getReadableDatabase() or
getWriteableDatabase(). This also means that any methods that call
getReadableDatabase() or getWriteableDatabase() should be done on a
background thread as there is a possibility that they might be kicking off the
initial creation of the database.
20. Establishing Connection
flutterjunction.com
A helper class to manage database creation and version management.
Requires overriding onCreate() and onUpgrade() methods.
SQLite database will be used across your entire application; within services,
applications, fragments, and more.
For this reason, best practices often advise you to apply the singleton pattern
to your SQLiteOpenHelper instances to avoid memory leaks and unnecessary
reallocations.
The best solution is to make your database instance a singleton instance across
the entire application's lifecycle.
SQLiteOpenHelper Class
28. Data Manipulation
flutterjunction.com
Keep In Mind
Use try-finally to ensure database resources are closed.
Keep database interactions on a background thread to avoid blocking the UI.
Use Singleton pattern for SQLiteOpenHelper to manage a single database
instance.
30. flutterjunction.com
Stands for Application Programming Interface.
Set of rules and protocols for building and interacting with software
applications.
Enables different software systems to communicate with each other.
API
32. flutterjunction.com
Web API architecture style.
Uses standard HTTP methods: GET, POST, PUT, DELETE.
Data often exchanged in JSON or XML format.
Types of API
REST (Representational State Transfer)
33. flutterjunction.com
Protocol for exchanging structured information.
XML-based messaging protocol.
Requires strict standards and more overhead.
Types of API
SOAP (Simple Object Access Protocol)
34. flutterjunction.com
Query language for APIs.
Allows clients to request only the data they need.
More flexible than REST but requires a different setup.
Types of API
GraphQL
35. flutterjunction.com
Stands for JavaScript Object Notation.
Lightweight data-interchange format.
Easy for humans to read and write, and easy for machines to parse and
generate.
Consists of key-value pairs.
Supports data types like strings, numbers, objects, arrays, booleans, and null.
Introduction to JSON