> ## Documentation Index
> Fetch the complete documentation index at: https://www.cometchat.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Threaded Messages Header

> Displays the parent message bubble and reply count for a threaded conversation.

`CometChatThreadHeader` renders the parent message bubble and reply count for a threaded conversation. It requires a parent message to display.

![](https://mintcdn.com/cometchat-22654f5b/T-kVUXtubs0NtFU5/images/ccfded5e-thread_header-02deacd1056bec41b2d4862bc713a4df.png?fit=max\&auto=format\&n=T-kVUXtubs0NtFU5\&q=85\&s=74e2a8e928d09731e3a29603a9b30b3d)

***

## Where It Fits

`CometChatThreadHeader` is a header component for threaded message views. Wire it above a `CometChatMessageList` and `CometChatMessageComposer` to build a complete threaded conversation layout.

> [tab] Kotlin (XML Views)
>
> ```xml activity_thread.xml lines theme={null}
> <com.cometchat.uikit.kotlin.presentation.threadheader.ui.CometChatThreadHeader
>     android:id="@+id/thread_header"
>     android:layout_width="match_parent"
>     android:layout_height="wrap_content" />
> ```
>
> ```kotlin lines theme={null}
> val threadHeader = findViewById<CometChatThreadHeader>(R.id.thread_header)
> threadHeader.setParentMessage(parentMessage)
> ```

> [tab] Jetpack Compose
>
> ```kotlin lines theme={null}
> CometChatThreadHeader(
>     parentMessage = parentMessage
> )
> ```

***

## Quick Start

> [tab] Kotlin (XML Views)
>
> Add to your layout XML:
>
> ```xml lines theme={null}
> <com.cometchat.uikit.kotlin.presentation.threadheader.ui.CometChatThreadHeader
>     android:id="@+id/thread_header"
>     android:layout_width="match_parent"
>     android:layout_height="wrap_content" />
> ```
>
> Set the parent message — this is required:
>
> ```kotlin lines theme={null}
> override fun onCreate(savedInstanceState: Bundle?) {
>     super.onCreate(savedInstanceState)
>     setContentView(R.layout.activity_thread)
>
>     val threadHeader = findViewById<CometChatThreadHeader>(R.id.thread_header)
>     threadHeader.setParentMessage(baseMessage)
> }
> ```

> [tab] Jetpack Compose
>
> ```kotlin lines theme={null}
> @Composable
> fun ThreadScreen() {
>     CometChatThreadHeader(
>         parentMessage = baseMessage
>     )
> }
> ```

Prerequisites: CometChat SDK initialized with `CometChatUIKit.init()`, a user logged in, and the UI Kit dependency added.

***

## Actions and Events

### Callback Methods

`CometChatThreadHeader` is a display-only header. It does not expose component-specific callbacks like `setOnItemClick` or `setOnError`. The one interactive element is the **subscription bell** — see [Thread Subscription](#thread-subscription) below.

### SDK Events (Real-Time, Automatic)

The component listens to SDK events internally via its ViewModel. No manual setup needed.

| SDK Listener | Internal behavior |
| - | - |
| Message edited | Updates the parent message bubble |
| Message deleted | Updates the parent message bubble |
| Reply count changed | Updates the reply count indicator |

***

## Functionality

| Method (Kotlin XML) | Compose Parameter | Description |
| - | - | - |
| `setParentMessage(message)` | `parentMessage = message` | Set the parent message (required) |
| `setUser(user)` | `user = user` | Set the user context |
| `setGroup(group)` | `group = group` | Set the group context |
| `setReactionVisibility(View.GONE)` | `hideReactions = true` | Toggle reactions on parent bubble |
| `setAvatarVisibility(View.GONE)` | `hideAvatar = true` | Toggle avatar visibility |
| `setReceiptsVisibility(View.GONE)` | `hideReceipts = true` | Toggle read receipts |
| `setReplyCountVisibility(View.GONE)` | `hideReplyCount = true` | Toggle reply count text |
| `setThreadSubscriptionVisibility(View.GONE)` | `hideThreadSubscription = true` | Toggle the subscription bell |
| `setOnThreadSubscriptionChange { }` | `onSubscriptionToggle = { }` | Subscription-state change callback |
| — | `threadSubscriptionView = { }` | Replace the bell with a custom composable |

***

## Thread Subscription

On Android the subscription bell belongs to `CometChatThreadHeader` — it renders as a trailing control on this component's reply-count row. Thread subscription is enabled by default from **v6.1.0**; on **v6.0.x** the bell renders only after `UIKitSettings.setEnableThreadSubscription(true)`. It flips optimistically on tap, reverts with a toast if the server rejects the change, and stays in step with the message list's Subscribe / Unsubscribe action sheet option.

> [tab] Kotlin (XML Views)
>
> ```kotlin lines theme={null}
> // Observe state changes (isSubscribed = the new state)
> threadHeader.setOnThreadSubscriptionChange { isSubscribed ->
>     Log.d(TAG, "Thread subscribed: $isSubscribed")
> }
>
> // Hide the bell on this screen
> threadHeader.setThreadSubscriptionVisibility(View.GONE)
> ```
>
> Visibility can also be set in XML via `app:cometchatThreadSubscriptionVisibility`.

> [tab] Jetpack Compose
>
> ```kotlin lines theme={null}
> CometChatThreadHeader(
>     parentMessage = parentMessage,
>     hideThreadSubscription = false,      // true to hide the built-in bell
>     isSubscribed = null,                 // null = seed from parentMessage.isThreadSubscribed()
>     onSubscriptionToggle = { isSubscribed -> },
>     threadSubscriptionView = null        // or your own composable replacing the bell
> )
> ```

To place the bell in the thread screen's **top title bar** instead (as the CometChat sample apps do), Compose exposes it standalone — hide this component's built-in bell and host `ThreadSubscriptionBell` in your own top bar:

```kotlin lines theme={null}
TopAppBar(
    title = { Text(stringResource(R.string.thread)) },
    actions = { ThreadSubscriptionBell(parentMessage = parentMessage) }
)

CometChatThreadHeader(
    parentMessage = parentMessage,
    hideThreadSubscription = true   // the bell lives in the top bar instead
)
```

This component's own `threadSubscriptionView` replaces the bell in the reply-count row. It is the escape hatch for putting your own control there — it does not move the bell to the top bar.

The same subscribe/unsubscribe action is also offered as a message option on [CometChatMessageList](https://www.cometchat.com/docs/ui-kit/android/message-list.md), hidden independently with `setThreadSubscriptionOptionVisibility(View.GONE)` — an integrator may want one surface and not the other. See the [Thread Subscription guide](https://www.cometchat.com/docs/ui-kit/android/guide-threaded-messages.md#thread-subscription) for the full feature.

***

## Style

> [tab] Kotlin (XML Views)
>
> Define a custom style in `themes.xml`:
>
> ```xml themes.xml lines theme={null}
> <style name="CustomOutgoingMessageBubbleStyle" parent="CometChatOutgoingMessageBubbleStyle">
>     <item name="cometchatMessageBubbleBackgroundColor">#F76808</item>
> </style>
>
> <style name="CustomIncomingMessageBubbleStyle" parent="CometChatIncomingMessageBubbleStyle">
>     <item name="cometchatMessageBubbleBackgroundColor">#F76808</item>
> </style>
>
> <style name="CustomThreadHeaderStyle" parent="CometChatThreadHeaderStyle">
>     <item name="cometchatThreadHeaderOutgoingMessageBubbleStyle">@style/CustomOutgoingMessageBubbleStyle</item>
>     <item name="cometchatThreadHeaderIncomingMessageBubbleStyle">@style/CustomIncomingMessageBubbleStyle</item>
>     <item name="cometchatThreadHeaderBackgroundColor">#FEEDE1</item>
>     <item name="cometchatThreadHeaderReplyCountTextColor">#F76808</item>
>     <item name="cometchatThreadHeaderReplyCountBackgroundColor">#FEEDE1</item>
> </style>
> ```
>
> ```kotlin lines theme={null}
> threadHeader.setStyle(R.style.CustomThreadHeaderStyle)
> ```

> [tab] Jetpack Compose
>
> ```kotlin lines theme={null}
> CometChatThreadHeader(
>     parentMessage = baseMessage,
>     style = CometChatThreadHeaderStyle.default().copy(
>         backgroundColor = Color(0xFFFEEDE1),
>         replyCountTextColor = Color(0xFFF76808),
>         replyCountBackgroundColor = Color(0xFFFEEDE1)
>     )
> )
> ```

![](https://mintcdn.com/cometchat-22654f5b/dDWpooIQ48haNjyU/images/76d4d00d-thread_header_styling-447011f9a5da276b357ce91cafa04e94.png?fit=max\&auto=format\&n=dDWpooIQ48haNjyU\&q=85\&s=7d71b478f3152857c13e812dc4c76d5c)

See [Component Styling](https://www.cometchat.com/docs/ui-kit/android/component-styling.md) for the full reference.

***

## ViewModel

```kotlin lines theme={null}
val viewModel = ViewModelProvider(this)
    .get(CometChatThreadHeaderViewModel::class.java)
```

> [tab] Kotlin (XML Views)
>
> ```kotlin lines theme={null}
> threadHeader.setViewModel(viewModel)
> ```

> [tab] Jetpack Compose
>
> ```kotlin lines theme={null}
> CometChatThreadHeader(
>     parentMessage = baseMessage,
>     threadHeaderViewModel = viewModel
> )
> ```

See [ViewModel & Data](https://www.cometchat.com/docs/ui-kit/android/customization-viewmodel-data.md) for state observation and custom repositories.

***

## Next Steps

> [card] [Message List](https://www.cometchat.com/docs/ui-kit/android/message-list.md)
>
> Display messages in a conversation

> [card] [Message Header](https://www.cometchat.com/docs/ui-kit/android/message-header.md)
>
> Display user/group info in the toolbar

> [card] [Message Composer](https://www.cometchat.com/docs/ui-kit/android/message-composer.md)
>
> Rich input for sending messages

> [card] [Conversations](https://www.cometchat.com/docs/ui-kit/android/conversations.md)
>
> Browse recent conversations


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.