AI Integration Quick Reference
AI Integration Quick Reference
Where It Fits
CometChatGroupMembers is a list component. It renders all members of a specific group and emits the selected GroupMember via setOnItemClick. It requires a Group object set via setGroup() before it can load data. Wire it to CometChatMessageHeader, CometChatMessageList, and CometChatMessageComposer to build a group messaging layout.
- Kotlin
- Java
GroupChatActivity.kt
Quick Start
Add the component to your layout XML:layout_activity.xml

CometChatUIKit.init(), a user logged in, the cometchat-chat-uikit-android dependency added, and a valid Group object with a group ID (GUID).
Set the Group object in your Activity or Fragment:
- Kotlin
- Java
YourActivity.kt
What this does: Creates aOr add programmatically in an Activity:Groupobject with a group ID and name, then passes it to theCometChatGroupMemberscomponent. The component fetches and displays all members of that group.
- Kotlin
- Java
YourActivity.kt
- Kotlin
- Java
YourFragment.kt
Filtering Group Members
Pass aGroupMembersRequest.GroupMembersRequestBuilder to setGroupMembersRequestBuilder. Pass the builder instance — not the result of .build().
- Kotlin
- Java
Filter Recipes
The component uses infinite scroll — the next page loads as the user scrolls to the bottom.
Search Request Builder
UsesetSearchRequestBuilder to customize the search list separately from the main list:
- Kotlin
- Java
What this does: Creates a GroupMembersRequestBuilder with a group ID, limit, and search keyword, then applies it as the search request builder. When the user searches, the component uses this builder to filter results.
Actions and Events
Callback Methods
setOnItemClick
Fires when a group member row is tapped. Primary navigation hook — set the active member and render the message view.
- Kotlin
- Java
YourActivity.kt
What this does: Replaces the default item-click behavior. When a user taps a group member, your custom lambda executes instead of the built-in navigation.
setOnItemLongClick
Fires when a group member row is long-pressed. Use for additional actions like kick, ban, or change scope.
- Kotlin
- Java
YourActivity.kt
setOnBackPressListener
Fires when the user presses the back button in the app bar. Default: navigates to the previous activity.
- Kotlin
- Java
YourActivity.kt
setOnSelection
Fires when a group member is checked/unchecked in multi-select mode. Requires setSelectionMode to be set.
- Kotlin
- Java
YourActivity.kt
setOnError
Fires on internal errors (network failure, auth issue, SDK exception).
- Kotlin
- Java
YourActivity.kt
setOnLoadMore
Fires when the list is successfully fetched and loaded.
- Kotlin
- Java
YourActivity.kt
setOnEmpty
Fires when the list is empty, enabling custom handling such as showing a placeholder.
- Kotlin
- Java
YourActivity.kt
- Verify: After setting an action callback, trigger the corresponding user interaction (tap, long-press, back, select) and confirm your custom logic executes instead of the default behavior.
Global UI Events
CometChatGroupEvents emits events subscribable from anywhere in the application. Add a listener and remove it when no longer needed.
- Kotlin
- Java
Add Listener
What this does: Registers a global event listener tagged with "LISTENER_TAG". When a group member is kicked, banned, or has their scope changed, the corresponding callback fires with the action details, affected user, and group information.
SDK Events (Real-Time, Automatic)
The component listens to these SDK events internally. No manual attachment needed unless additional side effects are required.Automatic: group membership changes and user presence changes update the list in real time.
Functionality
Small functional customizations such as toggling visibility of UI elements and configuring selection modes.- Verify: After calling a visibility method, confirm the corresponding UI element is shown or hidden.
Custom View Slots
Each slot replaces a section of the default UI. Slots that accept aGroupMember parameter receive the group member object for that row via the GroupMembersViewHolderListeners pattern (createView + bindView).
setLeadingView
Replace the avatar / left section.
- Kotlin
- Java
What this does: Registers aScope badge avatar example:GroupMembersViewHolderListenersthat provides a custom view for the leading (left) area of each group member item.createViewinflates your layout, andbindViewpopulates it with group member data.

custom_title_view.xml:
custom_title_view.xml
What this does: Defines a custom leading view layout with a CometChatAvatar and a role badge view that can display different backgrounds based on the member’s scope (admin, moderator, participant).
- Kotlin
- Java
YourActivity.kt
What this does: Inflates a custom leading view layout and populates it with the group member’s avatar and a role-based badge. If the member is an admin, the badge shows themarketing_headdrawable; if a moderator,sr_manager; if a participant,content_manager; otherwise,team_member. The view is sized to 40dp × 40dp.
setTitleView
Replace the name / title text.
- Kotlin
- Java

custom_title_view.xml:
custom_title_view.xml
What this does: Defines a custom title view layout with aTextViewfor the member name and aViewfor the role badge, arranged horizontally.
- Kotlin
- Java
YourActivity.kt
What this does: Inflates a custom title view layout and populates it with the group member’s name and a role-based badge. The badge background changes based on the member’s scope:marketing_headfor admin,sr_managerfor moderator,content_managerfor participant, andteam_memberfor others.
setSubtitleView
Replace the subtitle text below the member’s name.
- Kotlin
- Java

- Kotlin
- Java
YourActivity.kt
What this does: Creates aTextViewas the subtitle view and populates it with the group member’s join date formatted as “dd/MM/yyyy, HH:mm:ss”. ThejoinedAttimestamp is multiplied by 1000 to convert from seconds to milliseconds.
setTrailingView
Replace the right section of each group member item.
- Kotlin
- Java

custom_tail_view.xml:
custom_tail_view.xml
What this does: Defines a custom trailing view layout with aMaterialCardViewcontaining aTextViewthat displays the member’s scope as a colored badge.
- Kotlin
- Java
YourActivity.kt
What this does: Inflates a custom trailing view that displays a scope badge for each group member. The badge background uses the extended primary color, the text shows the member’s scope, and the badge is only visible for participants (hidden for admins, moderators, and owners).
setItemView
Replace the entire list item row.
- Kotlin
- Java

item_list.xml:
item_list.xml
What this does: Defines a custom list item layout with two TextView elements: one for the member name and one for the subtitle (scope), arranged vertically.
- Kotlin
- Java
YourActivity.kt
What this does: Inflates a custom list item layout and populates it with the group member’s name and scope. Each list item shows the member name in the primary text style and their scope (admin, moderator, participant) in the secondary text style.
setOptions
Replace the long-press context menu entirely.
- Kotlin
- Java
addOptions
Append to the long-press context menu without removing defaults.
- Kotlin
- Java
setLoadingStateView
Sets a custom loading view displayed when data is being fetched.
- Kotlin
- Java
setEmptyStateView
Configures a custom view displayed when there are no group members in the list.
- Kotlin
- Java
setErrorStateView
Defines a custom error state view that appears when an issue occurs while loading group members.
- Kotlin
- Java
setOverflowMenu
Replace the toolbar overflow menu.

- Kotlin
- Java
What this does: Creates an ImageView with an add icon and sets it as the overflow menu in the group members toolbar. This provides a quick action button for adding new members.
- Verify: After setting any custom view slot, confirm the custom view renders in the correct position within the group member list item, and the data binding populates correctly for each member.
Common Patterns
Hide all chrome — minimal list
- Kotlin
- Java
Admins-only list
- Kotlin
- Java
Exclude group owner
- Kotlin
- Java
Hide kick/ban/scope options
- Kotlin
- Java
Advanced Methods
Programmatic Selection
selectGroupMember
Programmatically selects or deselects a group member. Works with both SINGLE and MULTIPLE selection modes.
- Kotlin
- Java
InSINGLEmode, selecting a new member replaces the previous selection. InMULTIPLEmode, calling this on an already-selected member deselects it (toggle behavior).
getSelectedGroupMembers
Returns the list of currently selected GroupMember objects.
- Kotlin
- Java
Selected Group Members List
When using multi-select mode, a horizontal list of selected group members can be shown above the main list.Search Input Customization
The built-in search box can be customized programmatically:Internal Access
These methods provide direct access to internal components for advanced use cases.Use these only when the standard API is insufficient. Directly manipulating the adapter or ViewModel may conflict with the component’s internal state management.
Style
The component uses XML theme styles. Define a custom style with parentCometChatGroupMembersStyle in themes.xml, then apply with setStyle().

themes.xml
- Kotlin
- Java
What this does: Applies theTo know more such attributes, visit the attributes file.CustomGroupMembersStyletheme to theCometChatGroupMemberscomponent, changing the avatar, separator, title text, and back icon appearance.
Programmatic Style Properties
In addition to XML theme styles, the component exposes programmatic setters for fine-grained control:Checkbox Style Properties (Selection Mode)
When usingSINGLE or MULTIPLE selection mode, checkboxes appear on each item:
Customization Matrix
Next Steps
Groups
Browse and search available groups
Users
Browse and search available users
Conversations
Browse recent conversations
Message List
Display messages in a conversation