Part of Android Development - ISMIN
Course followed by students of Mines St Etienne, ISMIN - M2 Computer Science.
The goal is to refactor the app by introducing Fragments.
Preparatory work:
- Copy everything from previous TP (except the README)
Then:
- Create a
BookListFragment
fragment - Update its attributes and factory method (the one called
newInstance
) to handle aArrayList<Book>
- Move the
<RecyclerView>
from the layout ofMainActivity
to the one ofBookListFragment
- Do the same for all RecyclerView related logic
In MainActivity
:
- Add a
<ConstraintLayout>
in the layout - Add some code to create a
BookListFragment
fragment and display it
Then:
- Create a
CreateBookFragment
fragment, if you generate it you can keep onlyonCreateView
function and discard everything else - Move code and layout from
CreateBookActivity
toCreateBookFragment
- Create an interface
BookCreator
with aonBookCreated(book: Book)
- Use
onAttach
function to save a reference to the activity - Implement
BookCreator
interface inMainActivity
- Start Android Studio
- Select
Open an existing Android Studio project
and pick this directory
That's it! You can code!
No extra this time!