Skip to main content
CometChatMessageHeader is a header bar component that sits at the top of a chat screen, displaying the avatar, name, and status of the user or group in the conversation.

Where It Fits

CometChatMessageHeader sits at the top of a chat screen. Wire it alongside CometChatMessageList and CometChatMessageComposer to build a complete messaging layout.
activity_chat.xml

Quick Start

Add to your layout XML:
Set a User or Group on the component — this is required for it to display data:
Prerequisites: CometChat SDK initialized with CometChatUIKit.init(), a user logged in, and the UI Kit dependency added.

Actions and Events

Callback Methods

onBackPress

Fires when the user presses the back button in the header.

onError

Fires on internal errors (network failure, auth issue, SDK exception).

SDK Events (Real-Time, Automatic)

The component listens to these SDK events internally. No manual setup needed.

Functionality


Custom View Slots

Leading View

Replace the avatar / left section.

Subtitle View

Replace the subtitle text below the user’s or group’s name.

Trailing View

Replace the right section (action buttons).

Item View

Replace the entire default header with a fully customized layout.

Style

Define a custom style in themes.xml:
themes.xml
See Component Styling for the full reference.

ViewModel

See ViewModel & Data for state observation and custom repositories.

Next Steps

Message List

Display messages in a conversation

Message Composer

Rich input for sending messages

Component Styling

Detailed styling reference

ViewModel & Data

Custom ViewModels and repositories