Part of Android Development - ISMIN
Course followed by students of Mines St Etienne, ISMIN - M2 Computer Science.
TP3: RecyclerView
📝 Goal
The goal is to display a list of book using a RecyclerView
.
Preparatory work:
- From the previous TP copy:
Book
Bookshelf
MainActivity
,CreateBookActivity
and their layouts
- Add an instance of
Bookshelf
inMainActivity
to be able to store multiples books created usingCreateBookActivity
RecyclerView implementation:
- Create a
row_book
XML file inres/layout
. In this file, create a layout to display content of a book (title, author, date) - Create a
BookViewHolder
class and implement it as it's done in the course - Create a
BookAdapter
class and implement it as it's done in the course (the constructor should deal with aArrayList<Book>
) - Add a
<recycler-view>
in the layout of theMainActivity
- Link the RecyclerView and the BookAdapter in the
MainActivity
About UX:
- Add a menu in the Toolbar with a button to clear the list of books`
- Customize app theme
- Use a
FloatingActionButton
instead of a simpleButton
to navigate to `CreateBookActivity
🚀 Getting Started
- Start Android Studio
- Select
Open an existing Android Studio project
and pick this directory
That's it! You can code!
🛰 Extra
- Display the books in a grid instead of a list
- Add a button on each book of the list to be able to delete it
🔑 Solution
An implementation of the TP is available on solution
branch. To switch to the solution just do:
# Commit or revert your local changes
# git add . && git commit -m "YOUR_MSG"
# Update your repository
git pull
# Switch to `solution` branch
git checkout solution