Overview
CometChatGroups
functions as a standalone component designed to create a screen displaying a list of groups, with the added functionality of enabling groups to search for specific groups. Acting as a container component, CometChatGroups encapsulates and formats the CometChatListBase
and CometChatGroupList
components without introducing any additional behavior of its own.

Usage
Integration
The following code snippet illustrates how you can can launchCometChatGroups
.
Actions
Actions dictate how a component functions. They are divided into two types: Predefined and Group-defined. You can override either type, allowing you to tailor the behavior of the component to fit your specific needs.setOnItemClick
Function invoked when a Group item is clicked, typically used to open a Group profile or chat screen.YourActivity.java
setOnItemLongClick
Function executed when a Group item is long-pressed, allowing additional actions like delete or block.YourActivity.java
setOnBackPressListener
OnBackPressListener
is triggered when you press the back button in the app bar. It has a predefined behavior; when clicked, it navigates to the previous activity. However, you can override this action using the following code snippet.
YourActivity.java
setOnSelect
Called when a item from the fetched list is selected, useful for multi-selection features.YourActivity.java
OnError
This action doesn’t change the behavior of the component but rather listens for any errors that occur in the groups component.YourActivity.java
setOnLoad
Invoked when the list is successfully fetched and loaded, helping track component readiness.YourActivity.java
setOnEmpty
Called when the list is empty, enabling custom handling such as showing a placeholder message.YourActivity.java
Filters
Filters allow you to customize the data displayed in a list within a Component. You can filter the list based on your specific criteria, allowing for a more customized. Filters can be applied using RequestBuilders of Chat SDK.1. GroupsRequestBuilder
The GroupsRequestBuilder enables you to filter and customize the group list based on available parameters in GroupsRequestBuilder. This feature allows you to create more specific and targeted queries when fetching groups. The following are the parameters available in GroupsRequestBuilderProperty | Description | Code |
---|---|---|
Limit | Configure the maximum number of groups to fetch in a single request, optimizing pagination for smoother navigation. | .setLimit(Int) |
Search Keyword | Employed to retrieve groups that match the provided string, facilitating precise searches. | .setSearchKeyWord(String) |
Joined Only | Exclusively fetches joined groups. | .joinedOnly(boolean) |
Tags | Utilized to fetch groups containing the specified tags. | .setTags(List<String>) |
With Tags | Utilized to retrieve groups with specific tags. | .withTags(boolean) |
2. SearchRequestBuilder
The SearchRequestBuilder uses GroupsRequestBuilder enables you to filter and customize the search list based on available parameters in GroupsRequestBuilder. This feature allows you to keep uniformity between the displayed Groups List and searched Group List. ExampleEvents
Events are emitted by aComponent
. By using event you can extend existing functionality. Being global events, they can be applied in Multiple Locations and are capable of being Added or Removed.
The list of events emitted by the Groups component is as follows.
Events | Description |
---|---|
ccGroupCreated() | This will get triggered when the logged in user creates a group |
ccGroupDeleted() | This will get triggered when the logged in user deletes a group |
ccGroupLeft() | This will get triggered when the logged in user leaves a group |
ccGroupMemberScopeChanged() | This will get triggered when the logged in user changes the scope of another group member |
ccGroupMemberBanned() | This will get triggered when the logged in user bans a group member from the group |
ccGroupMemberKicked() | This will get triggered when the logged in user kicks another group member from the group |
ccGroupMemberUnbanned() | This will get triggered when the logged in user unbans a user banned from the group |
ccGroupMemberJoined() | This will get triggered when the logged in user joins a group |
ccGroupMemberAdded() | This will get triggered when the logged in user add new members to the group |
ccOwnershipChanged | This will get triggered when the logged in user transfer the ownership of their group to some other member |
1. Add CometChatGroupEvents
Listener’s
2. Removing CometChatGroupEvents
Listener’s
Customization
To fit your app’s design requirements, you can customize the appearance of the groups component. We provide exposed methods that allow you to modify the experience and behavior according to your specific needs.Style
Using Style you can customize the look and feel of the component in your app, These parameters typically control elements such as the color, size, shape, and fonts used within the component.
To know more such attributes, visit the attributes file.
Functionality
These are a set of small functional customizations that allow you to fine-tune the overall experience of the component. With these, you can change text, set custom icons, and toggle the visibility of UI elements. Below is a list of customizations along with corresponding code snippetsMethods | Description | Code |
---|---|---|
setBackIconVisibility | Used to toggle visibility for back button in the app bar | .setBackIconVisibility(View.VISIBLE); |
setToolbarVisibility | Used to toggle visibility for back button in the app bar | .setToolbarVisibility(View.GONE); |
setLoadingStateVisibility | Used to hide loading state while fetching groups | .setLoadingStateVisibility(View.GONE); |
setErrorStateVisibility | Used to hide error state on fetching groups | .setErrorStateVisibility(View.GONE); |
setEmptyStateVisibility | Used to hide empty state on fetching groups | .setEmptyStateVisibility(View.GONE); |
setSeparatorVisibility | Used to control visibility of Separators in the list view | .setSeparatorVisibility(View.GONE); |
setGroupTypeVisibility | Used to control visibility of status indicator shown for the group type | .setGroupTypeVisibility(View.GONE); |
setSearchBoxVisibility | Used to hide search box shown in the tool bar | .setSearchBoxVisibility(View.GONE); |
setSelectionMode | This method determines the selection mode for groups, enabling user to select either a single groups or multiple groups at once. | .setSelectionMode(UIKitConstants.SelectionMode.MULTIPLE); |
setSearchkeyword | Used for fetching groups matching the passed keywords | .setSearchkeyword("anything"); |
Advanced
For advanced-level customization, you can set custom views to the component. This lets you tailor each aspect of the component to fit your exact needs and application aesthetics. You can create and define your views, layouts, and UI elements and then incorporate those into the component.setOptions
Defines the available actions when users interact with a group item, such as long-pressing or swiping. Use Cases:- Enable actions like “Mute Notifications”, “Leave Group”, “Pin Group”.
- Provide admin-only actions like “Manage Members”, “Delete Group”.
addOptions
This method extends the existing set of actions available when Groups long press a Group item. Unlike setOptionsDefines, which replaces the default options, addOptionsAdds allows developers to append additional actions without removing the default ones. Example use cases include:- Adding a “Report Spam” action
- Introducing a “Save to Notes” option
- Integrating third-party actions such as “Share to Cloud Storage”
setLoadingView
Configures a custom loading view displayed while groups are being fetched. Use Cases:- Show a spinner with “Loading groups…” text.
- Display a skeleton loader for a smooth UI experience.
setEmptyView
Defines a view that appears when no groups are available. Use Cases:- Show a message like “No groups found, create one now!”.
- Display an illustration with a “Create New Group” button.
setErrorView
Configures the UI when an error occurs while fetching groups. Use Cases:- Display a retry button with “Failed to load groups, try again.”.
- Show a friendly error illustration.
setLeadingView
Sets a custom leading view that appears at the start of each group item. Use Cases:- Display the group profile picture.
- Add an icon indicating Public or Private groups.

custom_leading_avatar_view.xml
for more complex or unique list items.
Once this layout file is made, you would inflate it inside the createView()
method of the GroupsViewHolderListener
. The inflation process prepares the layout for use in your application:
Following this, you would use the bindView()
method to initialize and assign values to your individual views. This could include setting text on TextViews, images on ImageViews, and so on based on the properties of the Group object:
custom_leading_avatar_view.xml
setTitleView
Customizes the title view of each group item, which typically displays the group name. Use Cases:- Style group names with custom fonts and colors.
- Show a verified badge for official groups.

custom_title_view.xml
for more complex or unique list items.
Once this layout file is made, you would inflate it inside the createView()
method of the GroupsViewHolderListener
. The inflation process prepares the layout for use in your application:
Following this, you would use the bindView()
method to initialize and assign values to your individual views. This could include setting text on TextViews, images on ImageViews, and so on based on the properties of the Group object:
custom_title_view.xml
setTrailingView
Allows custom elements to be added at the end of each group item, such as buttons or indicators. Use Cases:- Show unread message counts.
- Add a quick Join or Leave button.

custom_tail_view.xml
for more complex or unique list items.
Once this layout file is made, you would inflate it inside the createView()
method of the GroupsViewHolderListener
. The inflation process prepares the layout for use in your application:
Following this, you would use the bindView()
method to initialize and assign values to your individual views. This could include setting text on TextViews, images on ImageViews, and so on based on the properties of the Group object:
custom_tail_view.xml
setItemView
Assigns a fully custom ListItem layout to the Groups component, replacing the default design. Use Cases:- Add a description below the group name.
- Customize layout to include additional metadata.

item_list.xml
for more complex or unique list items.
Once this layout file is made, you would inflate it inside the createView()
method of the GroupsViewHolderListener
. The inflation process prepares the layout for use in your application:
Following this, you would use the bindView()
method to initialize and assign values to your individual views. This could include setting text on TextViews, images on ImageViews, and so on based on the properties of the Group object:
custom_group_list_itemd.xml
YourActivity.java
setSubTitleView
Customizes the subtitle view for each group item, which typically displays extra information. Use Cases:- Show last message preview.
- Display the number of members.

subtitle_layout.xml
for more complex or unique list items.
Once this layout file is made, you would inflate it inside the createView()
method of the GroupsViewHolderListener
. The inflation process prepares the layout for use in your application:
Following this, you would use the bindView()
method to initialize and assign values to your individual views. This could include setting text on TextViews, images on ImageViews, and so on based on the properties of the Group object:
YourActivity.java
SetOverflowMenu
Customizes the overflow menu (three-dot ⋮ icon) with additional options. Use Cases:- Add options like “Invite Members”, “Report Group”.
- Enable admin-specific options like “Manage Group Settings”.

overflow_menu_layout.xml
as a custom view file. Which we will inflate and pass to .setOverflowMenu()
.
overflow_menu_layout.xml
setOverflowMenu
. You can get the child view reference and can handle click actions.
YourActivity.java