Implemented in my Android Studio project FriendlyChat available in codelab. But in the messages there is no date and time. How to implement the date and time in this project?
Here are the Friendly Chat codes
Could anyone help me?
Implemented in my Android Studio project FriendlyChat available in codelab. But in the messages there is no date and time. How to implement the date and time in this project?
Here are the Friendly Chat codes
Could anyone help me?
First, you would have to edit the FriendlyMessage
class and place an attribute that supports the Date and Time information. Class Calendar
or Date
is great for this. Here are more information for the Calendar
class.
Make the get and set methods, just as you have for the other attributes.
Next, you'll have to include in the message layout, item_message
, a TextView
to display the date and time. You will also have to change the Adapter's messages to display the information correctly.
Then you only change the populateViewHolder()
method to set the TextView
of the date with the method to capture the date of FriendlyMessage
.
If everything does not work, see how it shows the messages and the name and try copying the method to date.