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 –
- Replacing ScrollView with RecyclerView.
- Creating a list item XML with LinearLayout and TextView to hold post titles inside and a view to display a line.
- Creating the RecyclerViewAdapter and ViewHolder classes with the required methods.
- Updating the MainActivity with RecyclerView object. Using LinearLayoutManager to set the RecyclerView’s orientation to vertical. Setting the Adapter on the object.
- 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 –
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.