[DD App] Day 2 – Switching to RecyclerView

dd-app-day-3-switching-recyclerview

Hi all,

 

Today I went further in Delightfull Discoveries application development. And instead of a single textview, switched to a RecyclerView. That involved the following updations –

 

  1. Replacing ScrollView with RecyclerView.
  2. Creating a list item XML with LinearLayout and TextView to hold post titles inside and a view to display a line.
  3. Creating the RecyclerViewAdapter and ViewHolder classes with the required methods.
  4. Updating the MainActivity with RecyclerView object. Using LinearLayoutManager to set the RecyclerView’s orientation to vertical. Setting the Adapter on the object.
  5. Adding item click by making the ViewHolder class implement the View.OnClickListener interface. For now, when we click an item, Toast message is displayed.

Files Created:

  • PostAdapter [which extends RecyclerView.Adapter class. It creates view holder for each item and binds data to them],
  • PostAdapterViewHolder [as an inner class inside PostAdapter. Extends RecyclerView.ViewHolder class. It creates the view objects and binds them to the item’s layout file. It also handles click actions, for which we implement View.OnCLickListener]
  • PostAdapterOnClickListener [an interface to receive onCLick messages.]
  • post_list_item.xml [layout file for an item inside RecyclerView.]

Files Edited:

  • MainActivity.java,
  • activity_main.xml

This is how the app looks right now –

 

dd-app-day-2-switching-recyclerview RecyclerView showing post titles
RecyclerView showing post titles
dd-app-day-2-switching-recyclerview RecyclerView
Toast message on clicking an item

 

Today I spent 3 Pomodoros, ie, 1 hour and 15 minutes on this application development. You can follow the progress of this development by going through Day 0 and Day 1 posts.

That’s all for today,

See you in next update.