Skip to main content
{
  "component": "CometChatSearch",
  "package": "com.cometchat.chatuikit.search",
  "xmlElement": "<com.cometchat.chatuikit.search.CometChatSearch />",
  "description": "Real-time search interface for finding conversations and messages with filters, scopes, and customization options.",
  "primaryOutput": {
    "conversationClicked": {
      "method": "setOnConversationClicked",
      "type": "OnItemClick<Conversation>"
    },
    "messageClicked": {
      "method": "setOnMessageClicked",
      "type": "OnItemClick<BaseMessage>"
    }
  },
  "methods": {
    "data": {
      "setConversationsRequestBuilder": {
        "type": "ConversationsRequest.ConversationsRequestBuilder",
        "default": "SDK default",
        "note": "Pass the builder, not the result of .build()"
      },
      "setMessagesRequestBuilder": {
        "type": "MessagesRequest.MessagesRequestBuilder",
        "default": "SDK default",
        "note": "Pass the builder, not the result of .build()"
      }
    },
    "callbacks": {
      "setOnConversationClicked": "OnItemClick<Conversation>",
      "setOnMessageClicked": "OnItemClick<BaseMessage>",
      "setOnBackPressListener": "OnBackPress",
      "setOnError": "OnError",
      "setOnEmpty": "OnEmpty",
      "setOnLoadMessages": "OnLoad<BaseMessage>",
      "setOnLoadConversations": "OnLoad<Conversation>"
    },
    "visibility": {
      "setEmptyStateVisibility": { "type": "int (View.VISIBLE | View.GONE)", "default": "View.VISIBLE" },
      "setErrorStateVisibility": { "type": "int", "default": "View.VISIBLE" }
    },
    "functionality": {
      "setUid": { "type": "String", "note": "Scope search to a specific user conversation" },
      "setGuid": { "type": "String", "note": "Scope search to a specific group conversation" },
      "setSearchFilters": { "type": "List<UIKitConstants.SearchFilter>", "note": "Filters rendered as chips" },
      "setInitialSearchFilter": { "type": "UIKitConstants.SearchFilter", "note": "Default active filter on load" },
      "setSearchIn": { "type": "List<SearchScope>", "note": "Entities to search in" },
      "setHideGroupType": { "type": "boolean", "default": "false" },
      "setHideUserStatus": { "type": "boolean", "default": "false" }
    },
    "viewSlots": {
      "setConversationItemView": "ConversationsSearchViewHolderListener — entire conversation item row",
      "setTextMessageItemView": "MessagesSearchViewHolderListener<TextMessage> — text message item",
      "setImageMessageItemView": "MessagesSearchViewHolderListener<MediaMessage> — image message item",
      "setAudioMessageItemView": "MessagesSearchViewHolderListener<MediaMessage> — audio message item",
      "setVideoMessageItemView": "MessagesSearchViewHolderListener<MediaMessage> — video message item",
      "setDocumentMessageItemView": "MessagesSearchViewHolderListener<MediaMessage> — document message item",
      "setLinkMessageItemView": "MessagesSearchViewHolderListener<TextMessage> — link message item",
      "setInitialView": "@LayoutRes int — initial state before search",
      "setEmptyView": "@LayoutRes int — empty state",
      "setLoadingView": "View — loading state",
      "setErrorView": "View — error state"
    },
    "advanced": {
      "setTextFormatters": "List<CometChatTextFormatter> — custom text formatters",
      "setDateTimeFormatter": "DateTimeFormatterCallback — custom date/time formatting",
      "setMentionAllLabelId": "String id, String mentionAllLabel — custom mention-all label",
      "setHintText": "String — search bar hint text"
    },
    "style": {
      "setStyle": {
        "type": "@StyleRes int",
        "parent": "CometChatSearchStyle"
      }
    }
  },
  "events": [],
  "sdkListeners": []
}

Where It Fits

CometChatSearch is a composite search component. It searches across conversations and messages in real time and emits the selected result via setOnConversationClicked or setOnMessageClicked. Wire it to navigation so tapping a conversation opens the message view, or tapping a message scrolls to it in context.
ChatActivity.kt
class ChatActivity : AppCompatActivity() {

    private lateinit var search: CometChatSearch
    private lateinit var messageHeader: CometChatMessageHeader
    private lateinit var messageList: CometChatMessageList
    private lateinit var messageComposer: CometChatMessageComposer

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_chat)

        search = findViewById(R.id.cometchat_search)
        messageHeader = findViewById(R.id.message_header)
        messageList = findViewById(R.id.message_list)
        messageComposer = findViewById(R.id.message_composer)

        search.setOnConversationClicked { view, position, conversation ->
            val user = conversation.conversationWith as? User
            user?.let {
                messageHeader.setUser(it)
                messageList.setUser(it)
                messageComposer.setUser(it)
            }
        }

        search.setOnMessageClicked { view, position, baseMessage ->
            // Navigate to the message in context
        }
    }
}

Quick Start

Add the component to your layout XML:
activity_search.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".ui.activity.SearchActivity">

    <com.cometchat.chatuikit.search.CometChatSearch
        android:id="@+id/cometchat_search"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_constraintTop_toTopOf="parent"/>

</androidx.constraintlayout.widget.ConstraintLayout>
Prerequisites: CometChat SDK initialized with CometChatUIKit.init(), a user logged in, and the cometchat-chat-uikit-android dependency added. To add programmatically in an Activity:
SearchActivity.kt
class SearchActivity : AppCompatActivity() {
    private lateinit var binding: ActivitySearchBinding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivitySearchBinding.inflate(layoutInflater)
        setContentView(binding.root)
    }
}

Actions and Events

Callback Methods

setOnConversationClicked

Fires when a user taps a conversation from the search results. Primary navigation hook — set the active conversation and render the message view.
SearchActivity.kt
binding.cometchatSearch.setOnConversationClicked { view, position, conversation ->
    Log.i(TAG, "onCreate: Conversation Clicked !")
}
What this does: Replaces the default conversation-click behavior. When a user taps a conversation item, your custom lambda executes. The callback receives the view, position, and Conversation object.

setOnMessageClicked

Fires when a user taps a message from the search results. Use to navigate to the message in context.
SearchActivity.kt
binding.cometchatSearch.setOnMessageClicked { view, position, baseMessage ->
    Log.i(TAG, "onCreate: Message Clicked !")
}
What this does: Registers a callback that fires when the user taps a message in the search results. The callback receives the view, position, and BaseMessage object.

setOnBackPressListener

Fires when the user presses the back button in the search bar. Default: no predefined behavior.
SearchActivity.kt
binding.cometchatSearch.setOnBackPressListener {
    Log.i(TAG, "onCreate: Back Pressed !")
}

setOnError

Fires on internal errors (network failure, auth issue, SDK exception).
SearchActivity.kt
binding.cometchatSearch.onError = OnError {
    Log.i(TAG, "onCreate: Error Occurred ! ${it.message}")
}

setOnLoadMessages

Fires when the message list is successfully fetched and loaded, helping track when message search results are ready.
SearchActivity.kt
binding.cometchatSearch.setOnLoadMessages(OnLoad<BaseMessage> { list ->
    Log.i(TAG, "Messages loaded: ${list.size}")
})

setOnLoadConversations

Fires when the conversation list is successfully fetched and loaded, helping track when conversation search results are ready.
SearchActivity.kt
binding.cometchatSearch.setOnLoadConversations(OnLoad<Conversation> { list ->
    Log.i(TAG, "Conversations loaded: ${list.size}")
})

setOnEmpty

Fires when the search returns no results, enabling custom handling such as showing a placeholder.
SearchActivity.kt
binding.cometchatSearch.onEmpty = OnEmpty {
    Log.i(TAG, "onCreate: No Results Found !")
}
  • Verify: After setting an action callback, trigger the corresponding user interaction (tap a conversation result, tap a message result, press back, cause an error, or search for a term with no results) and confirm your custom logic executes.

Global UI Events

The CometChatSearch component does not produce any global UI events.

SDK Events (Real-Time, Automatic)

The CometChatSearch component does not listen to any SDK events internally. Search results are fetched on demand when the user types a query.

Functionality

Small functional customizations such as toggling visibility of UI elements and configuring search scope.
MethodsDescriptionCode
setEmptyStateVisibilityHides the empty state when search returns no results.setEmptyStateVisibility(View.GONE);
setErrorStateVisibilityHides the error state on search failure.setErrorStateVisibility(View.GONE);
setSearchFiltersList of filters rendered as chips in the search component.setSearchFilters(filters);
setInitialSearchFilterThe filter which will be active by default on load.setInitialSearchFilter(UIKitConstants.SearchFilter.MESSAGES);
setSearchInList of entities in which the search should be performed.setSearchIn(scopes);
setHideGroupTypeHides the group type icon in conversation leading view.setHideGroupType(true);
setHideUserStatusHides the user’s online/offline status indicator.setHideUserStatus(true);
  • Verify: After calling a visibility or functionality method, confirm the corresponding UI element is shown or hidden, or the search scope is correctly applied.

Custom View Slots

Each slot replaces a section of the default UI. Conversation item slots use the ConversationsSearchViewHolderListener pattern (createView + bindView). Message item slots use the MessagesSearchViewHolderListener pattern.
SlotMethodReplaces
Conversation item viewsetConversationItemView(ConversationsSearchViewHolderListener)Entire conversation item row
Text message itemsetTextMessageItemView(MessagesSearchViewHolderListener<TextMessage>)Text message item
Image message itemsetImageMessageItemView(MessagesSearchViewHolderListener<MediaMessage>)Image message item
Audio message itemsetAudioMessageItemView(MessagesSearchViewHolderListener<MediaMessage>)Audio message item
Video message itemsetVideoMessageItemView(MessagesSearchViewHolderListener<MediaMessage>)Video message item
Document message itemsetDocumentMessageItemView(MessagesSearchViewHolderListener<MediaMessage>)Document message item
Link message itemsetLinkMessageItemView(MessagesSearchViewHolderListener<TextMessage>)Link message item
Initial viewsetInitialView(@LayoutRes int)Initial state before search
Empty viewsetEmptyView(@LayoutRes int)Empty state
Loading viewsetLoadingView(View)Loading spinner
Error viewsetErrorView(View)Error state

setConversationItemView

Replace the entire conversation item row in search results.
SearchActivity.kt
binding.cometchatSearch.setConversationItemView(object : ConversationsSearchViewHolderListener() {
    override fun createView(context: Context?, listItem: View?): View? {
        return layoutInflater.inflate(R.layout.custom_conversation_search_item, null)
    }

    override fun bindView(
        context: Context?,
        createdView: View?,
        conversation: Conversation?,
        holder: RecyclerView.ViewHolder?,
        conversationList: List<Conversation?>?,
        position: Int
    ) {
        val titleTv = createdView?.findViewById<android.widget.TextView>(R.id.tv_title)
        conversation?.let {
            if (it.conversationType == CometChatConstants.CONVERSATION_TYPE_USER) {
                titleTv?.text = (it.conversationWith as User).name
            } else {
                titleTv?.text = (it.conversationWith as Group).name
            }
        }
    }
})
What this does: Registers a ConversationsSearchViewHolderListener for conversation items in search results. The createView method inflates a custom layout, and bindView populates it with the conversation name based on whether it’s a user or group conversation.

setTextMessageItemView

Replace the text message item view in search results. Define a custom layout XML:
custom_message_item_view.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:padding="16dp"
    android:background="#E8E4F3">

    <TextView
        android:id="@+id/tv_sender_name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="George Alan:"
        android:textColor="#6B4FBB"
        android:textSize="16sp"
        android:textStyle="bold"
        android:layout_marginEnd="4dp" />

    <TextView
        android:id="@+id/tv_message"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="That works for me. Yes, let's go a..."
        android:textColor="#4A4A4A"
        android:textSize="16sp"
        android:ellipsize="end"
        android:maxLines="1" />
</LinearLayout>
SearchActivity.kt
binding.cometchatSearch.setTextMessageItemView(object : MessagesSearchViewHolderListener<TextMessage>() {
    override fun createView(
        context: Context?,
        listItem: View?
    ): View? {
        return layoutInflater.inflate(R.layout.custom_message_item_view, null)
    }

    override fun bindView(
        context: Context?,
        createdView: View?,
        message: TextMessage?,
        holder: RecyclerView.ViewHolder?,
        messagesList: List<BaseMessage?>?,
        position: Int
    ) {
        val titleTv = createdView?.findViewById<android.widget.TextView>(R.id.tv_sender_name)
        val messageTv = createdView?.findViewById<android.widget.TextView>(R.id.tv_message)

        titleTv?.text = message?.sender?.name
        messageTv?.text = message?.text
    }
})
What this does: Registers a MessagesSearchViewHolderListener for text messages. The createView method inflates the custom layout, and bindView populates the sender name and message text from the TextMessage object.

Other Message Item Views

The following message item view methods follow the same MessagesSearchViewHolderListener pattern as setTextMessageItemView:
MethodMessage TypeGeneric Type
setImageMessageItemViewImage MessageMessagesSearchViewHolderListener<MediaMessage>
setVideoMessageItemViewVideo MessageMessagesSearchViewHolderListener<MediaMessage>
setAudioMessageItemViewAudio MessageMessagesSearchViewHolderListener<MediaMessage>
setDocumentMessageItemViewDocument MessageMessagesSearchViewHolderListener<MediaMessage>
setLinkMessageItemViewLink MessageMessagesSearchViewHolderListener<TextMessage>

setInitialView

Sets a custom view displayed when the search component is rendered and no search has been performed.
binding.cometchatSearch.setInitialView(R.layout.your_initial_view)

setEmptyView

Configures a custom view displayed when the search returns no results.
binding.cometchatSearch.setEmptyView(R.layout.your_empty_view)

setLoadingView

Sets a custom loading view displayed when search results are being fetched.
binding.cometchatSearch.setLoadingView(loadingView)

setErrorView

Defines a custom error state view that appears when an issue occurs while searching.
binding.cometchatSearch.setErrorView(errorView)
  • Verify: After setting any custom view slot, confirm the custom view renders in the correct position within the search result items, and the data binding populates correctly for each result.

Common Patterns

binding.cometchatSearch.setSearchFilters(
    listOf(UIKitConstants.SearchFilter.MESSAGES)
)
binding.cometchatSearch.setInitialSearchFilter(UIKitConstants.SearchFilter.MESSAGES)

Filter by message type

binding.cometchatSearch.setMessagesRequestBuilder(
    MessagesRequest.MessagesRequestBuilder().setLimit(10)
)

Scope search to a specific user

binding.cometchatSearch.setUid("user123")

Scope search to a specific group

binding.cometchatSearch.setGuid("group123")

Advanced Methods

Search Scope

setUid

Scopes the search to a specific user’s conversation.
binding.cometchatSearch.setUid("user123")

setGuid

Scopes the search to a specific group’s conversation.
binding.cometchatSearch.setGuid("group123")

Request Builders

setConversationsRequestBuilder

Sets a ConversationsRequest.ConversationsRequestBuilder to filter conversation search results. Pass the builder instance — not the result of .build(). For all available builder options, refer to the ConversationRequestBuilder documentation.
binding.cometchatSearch.setConversationsRequestBuilder(
    ConversationsRequest.ConversationsRequestBuilder().setLimit(10)
)

setMessagesRequestBuilder

Sets a MessagesRequest.MessagesRequestBuilder to filter message search results. For all available builder options, refer to the MessagesRequestBuilder documentation.
binding.cometchatSearch.setMessagesRequestBuilder(
    MessagesRequest.MessagesRequestBuilder().setLimit(5)
)

Text Formatters

setTextFormatters

Enables developers to define and apply text formatters that dynamically modify or transform message content before rendering it in the UI. Text formatters can be used for:
  • Automatically converting URLs into clickable links
  • Applying Markdown or rich text styling
  • Replacing certain words or patterns with emojis or predefined text
  • Censoring specific words for moderation
For implementation details, refer to the MentionsFormatter Guide.

Date/Time Formatting

setDateTimeFormatter

Provides a custom implementation of DateTimeFormatterCallback to configure how time and date values are displayed in search results.
import java.text.SimpleDateFormat
import java.util.*

binding.cometchatSearch.setDateTimeFormatter(object : DateTimeFormatterCallback {

    private val fullTimeFormatter = SimpleDateFormat("hh:mm a", Locale.getDefault())
    private val dateFormatter = SimpleDateFormat("dd MMM yyyy", Locale.getDefault())

    override fun time(timestamp: Long): String {
        return fullTimeFormatter.format(Date(timestamp))
    }

    override fun today(timestamp: Long): String {
        return "Today"
    }

    override fun yesterday(timestamp: Long): String {
        return "Yesterday"
    }

    override fun lastWeek(timestamp: Long): String {
        return "Last Week"
    }

    override fun otherDays(timestamp: Long): String {
        return dateFormatter.format(Date(timestamp))
    }

    override fun minutes(diffInMinutesFromNow: Long, timestamp: Long): String {
        return "$diffInMinutesFromNow mins ago"
    }

    override fun hours(diffInHourFromNow: Long, timestamp: Long): String {
        return "$diffInHourFromNow hrs ago"
    }
})
What this does: Provides a custom date/time formatter that displays “Today”, “Yesterday”, “Last Week” for recent messages, a “dd MMM yyyy” format for older messages, and relative time strings like “5 mins ago” or “2 hrs ago” for recent activity.

Other Advanced Methods

MethodTypeDescription
setMentionAllLabelIdString id, String mentionAllLabelSets a custom label for the “mention all” feature for a specific ID
setHintTextStringSets the hint text displayed in the search bar

Style

The component uses XML theme styles. Define a custom style with parent CometChatSearchStyle in themes.xml, then apply with setStyle().
themes.xml
    <style name="CustomSearchStyle" parent="CometChatSearchStyle">
        <item name="cometchatSearchBackgroundColor">#EDEAFA</item>

        <item name="cometchatSearchFilterChipTextAppearance">@style/textStyleTimesNewRoman</item>

        <item name="cometchatSearchSectionHeaderTextAppearance">@style/textStyleTimesNewRoman</item>
        <item name="cometchatSearchSectionHeaderBackgroundColor">#EDEAFA</item>

        <item name="cometchatSearchConversationItemBackgroundColor">#EDEAFA</item>
        <item name="cometchatSearchConversationSubtitleTextAppearance">@style/textStyleTimesNewRoman</item>
        <item name="cometchatSearchConversationTitleTextAppearance">@style/textStyleTimesNewRoman</item>
        <item name="cometchatSearchConversationTimestampTextAppearance">?attr/cometchatTextAppearanceCaption1Bold</item>

        <item name="cometchatSearchSeeMoreTextAppearance">@style/textStyleTimesNewRoman</item>

        <item name="cometchatSearchMessageItemBackgroundColor">#EDEAFA</item>
        <item name="cometchatSearchMessageTitleTextAppearance">@style/textStyleTimesNewRoman</item>
        <item name="cometchatSearchMessageSubtitleTextAppearance">@style/textStyleTimesNewRoman</item>
        <item name="cometchatSearchMessageTimestampTextAppearance">@style/textStyleTimesNewRoman</item>

        <item name="cometchatSearchBarTextAppearance">@style/textStyleTimesNewRoman</item>
    </style>

    <style name="textStyleTimesNewRoman">
        <item name="android:fontFamily">@font/times_new_roman_regular</item>
    </style>
What this does: Defines a custom search style that sets a light purple background color (#EDEAFA) for the search component, conversation items, and message items, and applies a Times New Roman font to all text elements including filter chips, section headers, conversation titles/subtitles, message titles/subtitles, timestamps, “see more” text, and the search bar.
binding.cometchatSearch.setStyle(R.style.CustomSearchStyle)
To view all available style attributes, visit the attributes file.

Programmatic Style Properties

In addition to XML theme styles, the component exposes programmatic setters for fine-grained control: Search Bar
MethodTypeDescription
setBackgroundColor@ColorInt intBackground color of the component
setSearchBarBackgroundColor@ColorInt intBackground color of the search bar
setSearchBarStrokeWidth@Dimension intStroke width of the search bar border
setSearchBarStrokeColor@ColorInt intStroke color of the search bar border
setSearchBarCornerRadius@Dimension intCorner radius of the search bar
setSearchBarTextColor@ColorInt intText color of the search bar input
setSearchBarTextAppearance@StyleRes intText appearance of the search bar input
setSearchBarHintTextColor@ColorInt intHint text color of the search bar
setBackIconDrawableCustom back icon drawable
setBackIconTint@ColorInt intTint color for the back icon
setClearIconDrawableCustom clear icon drawable
setClearIconTint@ColorInt intTint color for the clear icon
setSearchIconDrawableCustom search icon drawable
setSearchIconTint@ColorInt intTint color for the search icon
Filter Chips
MethodTypeDescription
setFilterChipBackgroundColor@ColorInt intBackground color of filter chips
setFilterChipSelectedBackgroundColor@ColorInt intBackground color of selected filter chips
setFilterChipTextColor@ColorInt intText color of filter chips
setFilterChipSelectedTextColor@ColorInt intText color of selected filter chips
setFilterChipTextAppearance@StyleRes intText appearance of filter chips
setFilterChipStrokeColor@ColorInt intStroke color of filter chips
setFilterChipSelectedStrokeColor@ColorInt intStroke color of selected filter chips
setFilterChipStrokeWidth@Dimension intStroke width of filter chips
setFilterChipCornerRadius@Dimension intCorner radius of filter chips
Section Headers
MethodTypeDescription
setSectionHeaderTextColor@ColorInt intText color for section headers
setSectionHeaderTextAppearance@StyleRes intText appearance for section headers
setSectionHeaderBackgroundColor@ColorInt intBackground color for section headers
Conversation Items
MethodTypeDescription
setConversationItemBackgroundColor@ColorInt intBackground color for conversation items
setConversationTitleTextColor@ColorInt intText color for conversation titles
setConversationTitleTextAppearance@StyleRes intText appearance for conversation titles
setConversationSubtitleTextColor@ColorInt intText color for conversation subtitles
setConversationSubtitleTextAppearance@StyleRes intText appearance for conversation subtitles
setConversationTimestampTextColor@ColorInt intText color for conversation timestamps
setConversationTimestampTextAppearance@StyleRes intText appearance for conversation timestamps
Message Items
MethodTypeDescription
setMessageItemBackgroundColor@ColorInt intBackground color for message items
setMessageTitleTextColor@ColorInt intText color for message titles
setMessageTitleTextAppearance@StyleRes intText appearance for message titles
setMessageSubtitleTextColor@ColorInt intText color for message subtitles
setMessageSubtitleTextAppearance@StyleRes intText appearance for message subtitles
setMessageTimestampTextColor@ColorInt intText color for message timestamps
setMessageTimestampTextAppearance@StyleRes intText appearance for message timestamps
setMessageLinkTextColor@ColorInt intText color for links in messages
setMessageLinkTextAppearance@StyleRes intText appearance for links in messages
Other Style Properties
MethodTypeDescription
setAvatarStyle@StyleRes intStyle for avatars in search results
setBadgeStyle@StyleRes intStyle for badges in search results
setSeeMoreTextColor@ColorInt intText color for “See more” links
setSeeMoreTextAppearance@StyleRes intText appearance for “See more” links
setDateSeparatorTextColor@ColorInt intText color for date separators
setDateSeparatorBackgroundColor@ColorInt intBackground color for date separators
setDateSeparatorTextAppearance@StyleRes intText appearance for date separators
setEmptyStateTextColor@ColorInt intTitle text color for the empty state
setEmptyStateTextAppearance@StyleRes intTitle text appearance for the empty state
setEmptyStateSubtitleTextColor@ColorInt intSubtitle text color for the empty state
setEmptyStateSubtitleTextAppearance@StyleRes intSubtitle text appearance for the empty state
setEmptyStateIconDrawableIcon for the empty state
setEmptyStateIconTint@ColorInt intTint for the empty state icon
setErrorStateTextColor@ColorInt intTitle text color for the error state
setErrorStateTextAppearance@StyleRes intTitle text appearance for the error state
setErrorStateSubtitleTextColor@ColorInt intSubtitle text color for the error state
setErrorStateSubtitleTextAppearance@StyleRes intSubtitle text appearance for the error state
setErrorStateIconDrawableIcon for the error state
setErrorStateIconTint@ColorInt intTint for the error state icon

Customization Matrix

What to changeWhereProperty/APIExample
Override behavior on conversation tapActivity/FragmentsetOnConversationClickedsetOnConversationClicked { v, pos, conv -> ... }
Override behavior on message tapActivity/FragmentsetOnMessageClickedsetOnMessageClicked { v, pos, msg -> ... }
Override back press behaviorActivity/FragmentsetOnBackPressListenersetOnBackPressListener { ... }
Scope search to a userActivity/FragmentsetUid(String).setUid("user123")
Scope search to a groupActivity/FragmentsetGuid(String).setGuid("group123")
Hide user online statusActivity/FragmentsetHideUserStatus(boolean).setHideUserStatus(true)
Hide group type iconActivity/FragmentsetHideGroupType(boolean).setHideGroupType(true)
Set search filtersActivity/FragmentsetSearchFilters(List).setSearchFilters(filters)
Set initial active filterActivity/FragmentsetInitialSearchFilter(SearchFilter).setInitialSearchFilter(UIKitConstants.SearchFilter.MESSAGES)
Set search scopeActivity/FragmentsetSearchIn(List<SearchScope>).setSearchIn(scopes)
Filter conversation resultsActivity/FragmentsetConversationsRequestBuilderSee Request Builders code above
Filter message resultsActivity/FragmentsetMessagesRequestBuilderSee Request Builders code above
Custom conversation item viewActivity/FragmentsetConversationItemView(ConversationsSearchViewHolderListener)See setConversationItemView code above
Custom text message item viewActivity/FragmentsetTextMessageItemView(MessagesSearchViewHolderListener)See setTextMessageItemView code above
Custom image message item viewActivity/FragmentsetImageMessageItemView(MessagesSearchViewHolderListener)See setTextMessageItemView pattern
Custom video message item viewActivity/FragmentsetVideoMessageItemView(MessagesSearchViewHolderListener)See setTextMessageItemView pattern
Custom audio message item viewActivity/FragmentsetAudioMessageItemView(MessagesSearchViewHolderListener)See setTextMessageItemView pattern
Custom document message item viewActivity/FragmentsetDocumentMessageItemView(MessagesSearchViewHolderListener)See setTextMessageItemView pattern
Custom link message item viewActivity/FragmentsetLinkMessageItemView(MessagesSearchViewHolderListener)See setTextMessageItemView pattern
Custom initial viewActivity/FragmentsetInitialView(@LayoutRes int).setInitialView(R.layout.your_initial_view)
Custom loading viewActivity/FragmentsetLoadingView(View).setLoadingView(loadingView)
Custom empty viewActivity/FragmentsetEmptyView(@LayoutRes int).setEmptyView(R.layout.your_empty_view)
Custom error viewActivity/FragmentsetErrorView(View).setErrorView(errorView)
Empty state visibilityActivity/FragmentsetEmptyStateVisibility(int).setEmptyStateVisibility(View.GONE)
Error state visibilityActivity/FragmentsetErrorStateVisibility(int).setErrorStateVisibility(View.GONE)
Change colors, fonts, spacingthemes.xmlCometChatSearchStyle<item name="cometchatSearchBackgroundColor">#EDEAFA</item>
Apply a custom styleActivity/FragmentsetStyle(int styleRes)binding.cometchatSearch.setStyle(R.style.CustomSearchStyle)
Search bar backgroundActivity/FragmentsetSearchBarBackgroundColor.setSearchBarBackgroundColor(color)
Filter chip colorsActivity/FragmentsetFilterChip* methods.setFilterChipBackgroundColor(color)
Section header styleActivity/FragmentsetSectionHeader* methods.setSectionHeaderTextColor(color)
Conversation item styleActivity/FragmentsetConversation* methods.setConversationTitleTextColor(color)
Message item styleActivity/FragmentsetMessage* methods.setMessageTitleTextColor(color)
Date/time formattingActivity/FragmentsetDateTimeFormatter(DateTimeFormatterCallback)See setDateTimeFormatter code above
Text formattersActivity/FragmentsetTextFormatters(List)See Text Formatters section
Search bar hint textActivity/FragmentsetHintText(String).setHintText("Search...")
Mention-all labelActivity/FragmentsetMentionAllLabelId(String, String).setMentionAllLabelId(id, label)
Callback on messages loadedActivity/FragmentsetOnLoadMessages(OnLoad<BaseMessage>).setOnLoadMessages { list -> ... }
Callback on conversations loadedActivity/FragmentsetOnLoadConversations(OnLoad<Conversation>).setOnLoadConversations { list -> ... }

Accessibility

The component renders a search bar with filter chips and scrollable result lists for conversations and messages. The search input is focusable and supports keyboard input. Filter chips respond to tap gestures and announce their selected state. For custom views provided via setConversationItemView or message item view setters, ensure you set android:contentDescription on visual-only elements so TalkBack can announce them. The default views handle this automatically.

Next Steps