type
and category
of a message, the appearance and behavior of the header, content, and footer sections of the message bubble,
setType()
you can set the type of CometChatMessage, This will map your MessageTemplate to the corresponding CometChatMessage. You can set the MessageTemplate Type using the following code snippet.
.setCategory()
you can set the category of a MessageTemplate. This will create a MessageTemplate with the specified category and link it with a CometChatMessage of the same category.
Please refer to our guide on Message Categories for a deeper understanding of message categories.
setHeaderView()
method allows you to assign a custom header view to the MessageBubble. By default, it is configured to display the sender’s name.
.setContentView()
method allows you to assign a custom content view to the MessageBubble. By default, it displays the Text Bubble, Image Bubble, File Bubble, Audio Bubble, or Video Bubble, depending on the message type.
.setFooterView()
method allows you to assign a custom Footer view to the MessageBubble. By default, it displays the receipt and timestamp.
.setBottomView()
method allows you to assign a custom Bottom view to the MessageBubble.By defuault is has buttons such as link previews or a ‘load more’ button for long messages.
.setBubbleView()
method allows you to assign a custom Bubble view to the MessageBubble. By default, headerView, contentView, and footerView together form a message bubble.
.setOptions()
lets you set the list of actions that a user can perform on a message. This includes actions like reacting to, editing, or deleting a message.
setTemplates
method.
You can apply MessageTemplates to MessagesList Component using the following code snippet.
.setHeaderView()
method of MessageTemplate allows you to add custom views to the header of your message bubbles. In the example below, we will add a custom layout custom_txt_header_layout.xml
to the header view of every text message in the MessageList.
.setContentView()
method of MessageTemplate allows you to add a custom view to the content of your message bubbles. In the example below, we will add a custom layout custom_message_content_layout.xml
to the content view of every text message in the MessageList.
.setStatusInfoView()
method of MessageTemplate allows you to add a custom status info to your message bubbles. In the example below, we will add a custom layout status_info_layout.xml
to the footerview and empty layout to the status info view view of every text message in the MessageList.
status_info_layout.xml
as the footer info view for every message. The bindView() method allows you to bind your custom view, which will be called every time a ViewHolder for that message type is bound.
.setBottomView()
method of MessageTemplate allows you to add a custom button view to your message bubbles. In the example below, we will add a custom layout custom_message_bottom_layout.xml
to the bottom view of every text message in the MessageList.
.setFooterView()
method of MessageTemplate allows you to add a footer view to your message bubbles. In the example below, we will add a custom layout custom_menu_layout.xml to the bottom view of every text message in the MessageList.
.setBubbleView()
method of MessageTemplate allows you to add a bubble view to your message bubbles. In the example below, we will add a custom layout custom_message_content_layout.xml to the bubble view of every text message in the MessageList.
.setOptions()
method in the MessageTemplate allows you to customize the options that appear in the action sheet when a message is long-pressed. By default, CometChat UI Kit provides a set of options like “Reply”, “Forward”, “Edit”, and “Delete”.
However, if you wish to override or modify these options, you can use the .setOptions()
method and pass a list of CometChatMessageOption
. This list of options will replace the default set.