Skip to main content
CometChatGroupMembers displays all users who are either added to or invited to a group, enabling them to participate in group discussions, access shared content, and engage in collaborative activities.

When to use this

  • You need a screen that lists all members of a specific group.
  • You want to show member avatars, names, and scope (admin, moderator, participant).
  • You need tap and long-press actions on group member items (view profile, kick, ban, change scope).
  • You want to filter group members by scope, search keyword, or custom request builders.
  • You need real-time updates when members are banned, kicked, or have their scope changed.
  • You want to customize the member list appearance with styles, custom views, or advanced layouts.

Prerequisites

  • CometChat SDK initialized with CometChatUIKit.init() and a user logged in.
  • The cometchat-chat-uikit-android dependency added to your project.
  • A valid Group object with a group ID (GUID) to pass to the component.
  • A valid layout_activity.xml or Activity/Fragment where you will place the component.

Quick start

  1. Open your layout_activity.xml file.
  2. Add the CometChatGroupMembers XML element:
layout_activity.xml
<com.cometchat.chatuikit.groupmembers.CometChatGroupMembers
    android:id="@+id/group_member"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />
What this does: Adds the CometChatGroupMembers component to your layout. It fills the available width and height and renders the group member list once a Group object is set.
  1. In your Activity or Fragment, get a reference to the component and set the Group object:
CometChatGroupMembers cometchatGroupMembers = binding.groupMember;

Group group = new Group();
group.setGuid("GROUP_ID");
group.setName("GROUP_NAME");

cometchatGroupMembers.setGroup(group);
What this does: Creates a Group object with a group ID and name, then passes it to the CometChatGroupMembers component. The component fetches and displays all members of that group.
  1. Build and run your app.
  2. Verify that the group member list appears with avatars, names, and member scopes.

Core concepts

  • CometChatGroupMembers: The main component class that renders the group member list. It requires a Group object set via setGroup().
  • Actions: Callbacks such as setOnItemClick, setOnItemLongClick, setOnBackPressListener, setOnSelect, setOnError, setOnLoad, and setOnEmpty that let you respond to user interactions.
  • Filters: Use GroupMembersRequest.GroupMembersRequestBuilder to filter members by limit, search keyword, or scopes.
  • Events: Global events emitted by the component (e.g., ccGroupMemberBanned, ccGroupMemberKicked, ccGroupMemberScopeChanged) that you can listen to from anywhere in your app using CometChatGroupEvents.
  • Style: XML theme styles (parent CometChatGroupMembersStyle) applied via setStyle() to customize colors, fonts, and sub-component styles.
  • Advanced views: Methods like setLeadingView, setTitleView, setSubtitleView, setTrailingView, setItemView, and setOverflowMenu that let you replace default UI elements with custom layouts.

Implementation

Actions

What you’re changing: How the component responds to user interactions such as taps, long-presses, back button, selection, errors, load completion, and empty states.
  • Where: Activity or Fragment where you hold a reference to CometChatGroupMembers.
  • Applies to: CometChatGroupMembers.
  • Default behavior: Predefined actions execute automatically (e.g., tapping a member opens the member profile, pressing back navigates to the previous screen).
  • Override: Call the corresponding setter method to replace the default behavior with your own logic.

setOnItemClick

Function invoked when a user item is clicked, used to open a user profile or chat screen.
YourActivity.java
cometchatUsers.setOnItemClick((view1, position, user) -> {
            
    });
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

Function executed when a user item is long-pressed, allowing additional actions like delete or block.
YourActivity.java
cometchatUsers.setOnItemLongClick((view1, position, user) -> {

    });
What this does: Replaces the default long-press behavior. When a user long-presses a group member, your custom lambda executes.

setOnBackPressListener

Triggered when the user presses the back button in the app bar. By default, it navigates to the previous activity.
YourActivity.java
cometchatUsers.setOnBackPressListener(() -> {
            
    });
What this does: Overrides the default back-press navigation. When the user taps the back button, your custom logic runs instead.

setOnSelect

Called when an item from the fetched list is selected, useful for multi-selection features.
YourActivity.java
cometchatUsers.setOnSelect(t -> {

    });
What this does: Registers a callback that fires when the user selects one or more group members. The callback receives the list of selected User objects.

setOnError

Listens for any errors that occur in the component. This does not change the component’s behavior.
YourActivity.java
cometchatUsers.setOnError(cometchatException -> {

    });
What this does: Registers an error listener. If the component encounters an error (e.g., network failure), your callback receives the CometChatException.

setOnLoad

Invoked when the list is successfully fetched and loaded, helping track component readiness.
YourActivity.java
cometchatUsers.setOnLoad(list -> {

});
What this does: Registers a callback that fires after the group member list is fetched and rendered. The callback receives the list of loaded User objects.

setOnEmpty

Called when the list is empty, enabling custom handling such as showing a placeholder message.
YourActivity.java
cometchatUsers.setOnEmpty(() -> {
            
    });
What this does: Registers a callback that fires when the group member list has no items. Use this to show a custom empty-state message or trigger other logic.
  • 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.

Filters

What you’re changing: Which group members appear in the list.
  • Where: Activity or Fragment where you hold a reference to CometChatGroupMembers.
  • Applies to: CometChatGroupMembers.
  • Default behavior: All members of the specified group are fetched and displayed.
  • Override: Create a GroupMembersRequest.GroupMembersRequestBuilder, configure it, and pass it to setGroupMembersRequestBuilder.
You can filter using the following parameters:
PropertyDescriptionCode
LimitSets the number of group members that can be fetched in a single request, suitable for pagination..setLimit(int)
Search KeywordUsed for fetching group members matching the passed string..setSearchKeyword(String)
ScopesUsed for fetching group members having matching scopes which may be of participant, moderator, admin, and owner..setScopes(List<String>)
  • Code:
GroupMembersRequest.GroupMembersRequestBuilder groupMembersRequestBuilder= new GroupMembersRequest.GroupMembersRequestBuilder(GUID).setLimit(limit);

cometchatGroupMembers.setGroupMembersRequestBuilder(groupMembersRequestBuilder);
What this does: Creates a GroupMembersRequestBuilder with a group ID and a limit on the number of members fetched per request. The builder is then applied to the CometChatGroupMembers component.
  • Verify: The group member list shows only the specified number of members per fetch request.

SearchRequestBuilder

The SearchRequestBuilder uses GroupMembersRequest.GroupMembersRequestBuilder to filter and customize the search list based on available parameters. This keeps uniformity between the displayed group members list and the searched group members list.
GroupMembersRequest.GroupMembersRequestBuilder groupMembersRequestBuilder= new GroupMembersRequest.GroupMembersRequestBuilder(GUID).setLimit(LIMIT).setSearchKeyword(SEARCH_KEYWORD);

cometchatGroupMembers.setSearchRequestBuilder(groupMembersRequestBuilder);
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.
  • Verify: Searching in the group members list returns only members matching the specified keyword and limit.

Events

What you’re changing: How your app reacts to global events emitted by the Group Members component.
  • Where: Any Activity, Fragment, or class where you want to listen for group member events.
  • Applies to: CometChatGroupEvents.
  • Default behavior: No external listeners are registered. Events are emitted but not handled outside the component.
  • Override: Add a listener using CometChatGroupEvents.addGroupListener and remove it when no longer needed using CometChatGroupEvents.removeListener.
The following events are emitted:
EventDescription
ccGroupMemberBannedTriggers when the group member is banned from the group successfully
ccGroupMemberKickedTriggers when the group member is kicked from the group successfully
ccGroupMemberScopeChangedTriggers when the group member scope is changed in the group
  • Code:
CometChatGroupEvents.addGroupListener("LISTENER_ID", new CometChatGroupEvents() {
    @Override
    public void ccGroupMemberKicked(Action actionMessage, User kickedUser, User kickedBy, Group kickedFrom) {
        super.ccGroupMemberKicked(actionMessage, kickedUser, kickedBy, kickedFrom);
    }

    @Override
    public void ccGroupMemberBanned(Action actionMessage, User bannedUser, User bannedBy, Group bannedFrom) {
        super.ccGroupMemberBanned(actionMessage, bannedUser, bannedBy, bannedFrom);
    }

    @Override
    public void ccGroupMemberScopeChanged(Action actionMessage, User updatedUser, String scopeChangedTo, String scopeChangedFrom, Group group) {
        super.ccGroupMemberScopeChanged(actionMessage, updatedUser, scopeChangedTo, scopeChangedFrom, group);
    }

});
What this does: Registers a global event listener tagged with "LISTENER_ID". 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.
To remove the listener:
CometChatGroupEvents.removeListener("LISTENER_ID");
What this does: Removes the previously registered group event listener identified by "LISTENER_ID". Call this when you no longer need to listen for group member events.
  • Verify: Kick or ban a group member in the UI and confirm your ccGroupMemberKicked or ccGroupMemberBanned callback fires with the correct user and group objects.

Style

What you’re changing: The visual appearance of the Group Members component using XML theme styles.
  • Where: themes.xml for style definitions, and your Activity/Fragment for applying the style.
  • Applies to: CometChatGroupMembers.
  • Default behavior: The component uses the default CometChatGroupMembersStyle.
  • Override: Define a custom style with parent CometChatGroupMembersStyle in themes.xml, then call setStyle() on the component.
  • Code:
themes.xml
     <style name="CustomAvatarStyle" parent="CometChatAvatarStyle">
        <item name="cometchatAvatarStrokeRadius">8dp</item>
        <item name="cometchatAvatarBackgroundColor">#FBAA75</item>
    </style>

    <style name="CustomGroupMembersStyle" parent="CometChatGroupMembersStyle">
        <item name="cometchatGroupMembersAvatarStyle">@style/CustomAvatarStyle</item>
        <item name="cometchatGroupMembersSeparatorColor">#F76808</item>
        <item name="cometchatGroupMembersTitleTextColor">#F76808</item>
        <item name="cometchatGroupMembersBackIconTint">#F76808</item>
    </style>
What this does: Defines two custom styles: CustomAvatarStyle sets the avatar corner radius to 8dp and background color to #FBAA75; CustomGroupMembersStyle applies the custom avatar style and sets the separator color, title text color, and back icon tint to #F76808.
cometchatGroupMembers.setStyle(R.style.CustomGroupMembersStyle);
What this does: Applies the CustomGroupMembersStyle theme to the CometChatGroupMembers component, changing the avatar, separator, title text, and back icon appearance.
To know more such attributes, visit the attributes file.
  • Verify: The group member list avatars display with rounded corners (8dp radius) and an orange background (#FBAA75), and the separator, title text, and back icon appear in orange (#F76808).

Functionality

What you’re changing: Small functional customizations such as toggling visibility of UI elements and configuring selection modes.
  • Where: Activity or Fragment where you hold a reference to CometChatGroupMembers.
  • Applies to: CometChatGroupMembers.
  • Default behavior: All UI elements are visible with default settings.
  • Override: Call the corresponding method on the component instance.
MethodsDescriptionCode
setGroupSets the group whose members need to be fetched. This is a required property for the component to function properly..setGroup(group);
setBackIconVisibilityToggles visibility for the back button in the app bar.setBackIconVisibility(View.VISIBLE);
setToolbarVisibilityToggles visibility for the toolbar in the app bar.setToolbarVisibility(View.GONE);
setErrorStateVisibilityHides the error state on fetching members.setErrorStateVisibility(View.GONE);
setEmptyStateVisibilityHides the empty state on fetching members.setEmptyStateVisibility(View.GONE);
setLoadingStateVisibilityHides the loading state while fetching members.setLoadingStateVisibility(View.GONE);
setSeparatorVisibilityControls visibility of separators in the list view.setSeparatorVisibility(View.GONE);
setUsersStatusVisibilityControls visibility of the status indicator shown if a user is online.setUsersStatusVisibility(View.GONE);
setSelectionModeDetermines the selection mode for members, enabling users to select either a single or multiple members at once..setSelectionMode(UIKitConstants.SelectionMode.MULTIPLE);
setSearchkeywordUsed for fetching members matching the passed keywords.setSearchkeyword("anything");
setSearchBoxVisibilityHides the search box shown in the toolbar.setSearchBoxVisibility(View.GONE);
  • Verify: After calling a visibility method, confirm the corresponding UI element is shown or hidden. After calling setSelectionMode(UIKitConstants.SelectionMode.MULTIPLE), confirm that multiple members can be selected.

Advanced views

What you’re changing: The default UI elements of group member list items and the component’s chrome (loading, empty, error states, options, overflow menu).
  • Where: Activity or Fragment where you hold a reference to CometChatGroupMembers.
  • Applies to: CometChatGroupMembers.
  • Default behavior: The component renders its built-in views for each part of the group member item and component chrome.
  • Override: Call the corresponding setter method and provide a custom view or callback.

setOptions

Sets a predefined list of actions that users can perform when they interact with a group member item. This replaces the default options entirely.
cometchatUsers.setOptions((context, user) -> Collections.emptyList());
What this does: Replaces the default interaction options with an empty list, effectively removing all menu items when interacting with a group member.

addOptions

Extends the existing set of actions without removing the default ones.
cometchatUsers.addOptions((context, user) -> Collections.emptyList());
What this does: Appends an empty list to the existing interaction options, leaving the defaults unchanged. Replace the empty list with your custom MenuItem objects to add new actions.

setLoadingView

Sets a custom loading view displayed while group members are being fetched.
cometchatUsers.setLoadingView(R.layout.your_loading_view);
What this does: Replaces the default loading spinner with your custom layout resource. The custom view displays while group members are being fetched.

setEmptyView

Configures a custom view displayed when no group members are found.
cometchatUsers.setEmptyView(R.layout.your_empty_view);
What this does: Replaces the default empty state with your custom layout resource. The custom view displays when the group member list has no items.

setErrorView

Defines a custom error state view when there is an issue loading group members.
cometchatUsers.setErrorView(R.layout.your_empty_view);
What this does: Replaces the default error state with your custom layout resource. The custom view displays when the component encounters an error during data fetching.

setLeadingView

Sets a custom leading view for each group member item, used for profile images or avatars.
cometchatUsers.setLeadingView(new UsersViewHolderListener() {
            @Override
            public View createView(Context context, CometchatListBaseItemsBinding listItem) {
                return null;
            }

            @Override
            public void bindView(Context context, View createdView, User user, RecyclerView.ViewHolder holder, List<User> userList, int position) {

            }
        });
What this does: Registers a UsersViewHolderListener that provides a custom view for the leading (left) area of each group member item. createView inflates your layout, and bindView populates it with user data.
Create a custom layout file named custom_title_view.xml:
custom_title_view.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="@dimen/cometchat_45dp"
    android:layout_height="@dimen/cometchat_45dp"
    android:orientation="vertical">

    <com.cometchat.chatuikit.shared.views.avatar.CometChatAvatar
        android:id="@+id/avatar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <View
        android:id="@+id/batch_view"
        android:layout_width="match_parent"
        android:layout_height="@dimen/cometchat_12dp"
        android:layout_alignParentBottom="true"
        android:background="@drawable/admin_batch"
        android:visibility="gone" />

</RelativeLayout>
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).
Inflate the layout inside createView() of GroupMembersViewHolderListeners and use bindView() to set the avatar and role badge based on the member’s scope:
YourActivity.java
cometchatGroupMembers.setTitleView(new GroupMembersViewHolderListeners() {
            @Override
            public View createView(Context context, CometchatGroupMemberListItemBinding listItem) {
            return LayoutInflater.from(context).inflate(R.layout.header_leading_view, null, false);


            }

            @Override
            public void bindView(Context context, View createdView, GroupMember groupMember, Group group, RecyclerView.ViewHolder holder, List<GroupMember> groupMemberList, int position) {
                CometChatAvatar avatar = createdView.findViewById(R.id.avatar);
                avatar.setAvatar(groupMember.getName(), groupMember.getAvatar());
                View role = createdView.findViewById(R.id.batch_view);
                if (UIKitConstants.GroupMemberScope.ADMIN.equals(groupMember.getScope())) {
                    role.setVisibility(View.VISIBLE);
                    role.setBackground(ResourcesCompat.getDrawable(getResources(), R.drawable.marketing_head, null));
                } else if (UIKitConstants.GroupMemberScope.MODERATOR.equals(groupMember.getScope())) {
                    role.setVisibility(View.VISIBLE);
                    role.setBackground(ResourcesCompat.getDrawable(getResources(), R.drawable.sr_manager, null));
                } else if (UIKitConstants.GroupMemberScope.PARTICIPANTS.equals(groupMember.getScope())) {
                    role.setVisibility(View.VISIBLE);
                    role.setBackground(ResourcesCompat.getDrawable(getResources(), R.drawable.content_manager, null));
                } else {
                    role.setBackground(ResourcesCompat.getDrawable(getResources(), R.drawable.team_member, null));
                }
                LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(Utils.convertDpToPx(context, 40),
                                                                                       Utils.convertDpToPx(context, 40));
                createdView.setLayoutParams(layoutParams);
            }
        });
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 the marketing_head drawable; if a moderator, sr_manager; if a participant, content_manager; otherwise, team_member. The view is sized to 40dp × 40dp.

setTitleView

Customizes the title view, displaying the member’s name.
cometchatUsers.setTitleView(new UsersViewHolderListener() {
            @Override
            public View createView(Context context, CometchatListBaseItemsBinding listItem) {
                return null;
            }

            @Override
            public void bindView(Context context, View createdView, User user, RecyclerView.ViewHolder holder, List<User> userList, int position) {

            }
        });
What this does: Registers a UsersViewHolderListener that provides a custom view for the title area of each group member item. createView inflates your layout, and bindView populates it with user data.
Create a custom layout file named custom_title_view.xml:
custom_title_view.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/user_layout"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:gravity="center_vertical"
    android:orientation="horizontal">

    <TextView
        android:id="@+id/title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="teacher"
        android:textAppearance="?attr/cometchatTextAppearanceHeading4Medium"
        android:textColor="?attr/cometchatTextColorPrimary" />

    <View
        android:id="@+id/role"
        android:layout_width="50dp"
        android:layout_height="15dp"
        android:layout_marginStart="@dimen/cometchat_16dp"
        android:background="@drawable/team_member" />
</LinearLayout>
What this does: Defines a custom title view layout with a TextView for the member name and a View for the role badge, arranged horizontally.
Inflate the layout inside createView() of GroupMembersViewHolderListeners and use bindView() to set the name and role badge:
YourActivity.java
cometchatGroupMembers.setTitleView(new GroupMembersViewHolderListeners() {
            @Override
            public View createView(Context context, CometchatGroupMemberListItemBinding listItem) {
            return LayoutInflater.from(context).inflate(R.layout.custom_title_view, null, false);

            }

            @Override
            public void bindView(Context context, View createdView, GroupMember groupMember, Group group, RecyclerView.ViewHolder holder, List<GroupMember> groupMemberList, int position) {
                            LinearLayout layout = createdView.findViewById(R.id.user_layout);
                LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                                                                                       ViewGroup.LayoutParams.WRAP_CONTENT);
                layout.setLayoutParams(layoutParams);
                TextView name = createdView.findViewById(R.id.title);
                name.setText(groupMember.getName());
                View role = createdView.findViewById(R.id.role);
                if (UIKitConstants.GroupMemberScope.ADMIN.equals(groupMember.getScope())) {
                    role.setVisibility(View.VISIBLE);
                    role.setBackground(ResourcesCompat.getDrawable(getResources(), R.drawable.marketing_head, null));
                } else if (UIKitConstants.GroupMemberScope.MODERATOR.equals(groupMember.getScope())) {
                    role.setVisibility(View.VISIBLE);
                    role.setBackground(ResourcesCompat.getDrawable(getResources(), R.drawable.sr_manager, null));
                } else if (UIKitConstants.GroupMemberScope.PARTICIPANTS.equals(groupMember.getScope())) {
                    role.setVisibility(View.VISIBLE);
                    role.setBackground(ResourcesCompat.getDrawable(getResources(), R.drawable.content_manager, null));
                } else {
                    role.setBackground(ResourcesCompat.getDrawable(getResources(), R.drawable.team_member, null));

                }
            }
        });
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_head for admin, sr_manager for moderator, content_manager for participant, and team_member for others.

setItemView

Assigns a fully custom list item layout to the Group Members component, replacing the default structure entirely.
cometchatGroupMembers.setItemView(new GroupMembersViewHolderListeners() {
    @Override
    public View createView(Context context, CometchatGroupMemberListItemBinding cometChatListItem) {
        return null;
    }

    @Override
    public void bindView(Context context, View view, GroupMember groupMember, Group group, RecyclerView.ViewHolder viewHolder, List<GroupMember> list, int i) {

    }
});
What this does: Registers a GroupMembersViewHolderListeners that replaces the entire default group member list item layout. createView inflates your custom layout, and bindView populates it with group member data.
Create a custom layout file named item_list.xml:
item_list.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">


    <TextView
        android:id="@+id/tvName"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:maxLines="1"
        android:textAppearance="?attr/cometchatTextAppearanceHeading4Bold"
        android:textColor="?attr/cometchatTextColorPrimary" />

    <TextView
        android:id="@+id/tvSubtitle"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="@dimen/cometchat_margin_1"
        android:textAppearance="?attr/cometchatTextAppearanceBodyRegular"
        android:textColor="?attr/cometchatTextColorSecondary" />
</LinearLayout>
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.
Inflate the layout inside createView() and use bindView() to set the name and scope:
YourActivity.java
cometchatGroupMembers.setItemView(new GroupMembersViewHolderListeners() {
            @Override
            public View createView(Context context, CometchatGroupMemberListItemBinding listItem) {
                return View.inflate(context, R.layout.custom_group_list_item, null);
            }

            @Override
            public void bindView(Context context, View createdView, GroupMember groupMember, Group group, RecyclerView.ViewHolder holder, List<GroupMember> groupMemberList, int position) {
                TextView tvName = createdView.findViewById(R.id.tvName);
                TextView tvScope = createdView.findViewById(R.id.tvSubtitle);
                tvName.setText(groupMember.getName());
                tvScope.setText(groupMember.getScope());
            }
        });
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.

setSubTitleView

Customizes the subtitle view for each group member, used for extra details such as join date.
cometchatGroupMembers.setSubtitleView(new GroupMembersViewHolderListeners() {
    @Override
    public View createView(Context context, CometchatGroupMemberListItemBinding cometChatListItem) {
        return null;
    }

    @Override
    public void bindView(Context context, View view, GroupMember groupMember, Group group, RecyclerView.ViewHolder viewHolder, List<GroupMember> list, int i) {

    }
});
What this does: Registers a GroupMembersViewHolderListeners that provides a custom view for the subtitle area of each group member item. createView inflates your layout, and bindView populates it with group member data.
Inflate a TextView in createView() and use bindView() to display the member’s join date:
YourActivity.java
cometchatGroupMembers.setSubtitleView(new GroupMembersViewHolderListeners() {
            @Override
            public View createView(Context context, CometchatGroupMemberListItemBinding listItem) {
                return new TextView(context);
            }

            @Override
            public void bindView(Context context, View createdView, GroupMember groupMember, Group group, RecyclerView.ViewHolder holder, List<GroupMember> groupMemberList, int position) {
                ((TextView) createdView).setText("Joined at: "+new SimpleDateFormat("dd/mm/yyyy").format(groupMember.getJoinedAt()*1000));
            }
        });
What this does: Creates a TextView as the subtitle view and populates it with the group member’s join date formatted as “dd/mm/yyyy”. The joinedAt timestamp is multiplied by 1000 to convert from seconds to milliseconds.

setTrailingView

Customizes the trailing (right-end) section of each member item, used for action buttons or scope badges.
cometchatGroupMembers.setTrailingView(new GroupMembersViewHolderListeners() {
    @Override
    public View createView(Context context, CometchatGroupMemberListItemBinding cometChatListItem) {
        return null;
    }

    @Override
    public void bindView(Context context, View view, GroupMember groupMember, Group group, RecyclerView.ViewHolder viewHolder, List<GroupMember> list, int i) {

    }
});
What this does: Registers a GroupMembersViewHolderListeners that provides a custom view for the trailing (right) area of each group member item. createView inflates your layout, and bindView populates it with group member data.
Create a custom layout file named custom_tail_view.xml:
custom_tail_view.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

    <com.google.android.material.card.MaterialCardView
        android:id="@+id/scope_card"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="16dp"
        app:cardBackgroundColor="?attr/cometchatPrimaryColor"
        app:cardCornerRadius="@dimen/cometchat_radius_max"
        app:cardElevation="@dimen/cometchat_0dp"
     >

        <TextView
            android:id="@+id/tv_scope"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:paddingStart="@dimen/cometchat_padding_3"
            android:paddingTop="@dimen/cometchat_padding_1"
            android:paddingEnd="@dimen/cometchat_padding_3"
            android:paddingBottom="@dimen/cometchat_padding_1"
            android:text="@string/cometchat_owner"
            android:textAppearance="?attr/cometchatTextAppearanceCaption1Regular"
            android:textColor="?attr/cometchatPrimaryColor" />

    </com.google.android.material.card.MaterialCardView>

</LinearLayout>
What this does: Defines a custom trailing view layout with a MaterialCardView containing a TextView that displays the member’s scope as a colored badge.
Inflate the layout and use bindView() to set the scope text and visibility:
YourActivity.java
cometchatGroupMembers.setTrailingView(new GroupMembersViewHolderListeners() {
            @Override
            public View createView(Context context, CometchatGroupMemberListItemBinding listItem) {
                return View.inflate(context, R.layout.custom_tail_view, null);
            }

            @Override
            public void bindView(Context context, View createdView, GroupMember groupMember, Group group, RecyclerView.ViewHolder holder, List<GroupMember> groupMemberList, int position) {
                MaterialCardView cardView = createdView.findViewById(R.id.scope_card);
                TextView tvName = createdView.findViewById(R.id.tv_scope);
                cardView.setCardBackgroundColor(CometChatTheme.getExtendedPrimaryColor100(context));
                tvName.setText(groupMember.getScope());
                createdView.setVisibility(groupMember.getScope().equals(UIKitConstants.GroupMemberScope.PARTICIPANTS) ? View.VISIBLE : View.GONE);
            }
        });
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).

setOverflowMenu

Customizes the overflow menu (three-dot ⋮ icon) with additional options in the toolbar.
cometchatGroupMembers.setOverflowMenu(v);
What this does: Sets a custom View as the overflow menu in the group members toolbar. Pass any view (e.g., an icon button) to replace the default overflow menu.
ImageView addMemberIv = new ImageView(this);
addMemberIv.setImageDrawable(ResourcesCompat.getDrawable(getResources(), R.drawable.ic_add, null));
cometchatGroupMembers.setOverflowMenu(addMemberIv);
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 advanced view, confirm the custom view renders in the correct position within the group member list item, and the data binding populates correctly for each member.

Customization matrix

What you want to changeWhereProperty/APIExample
Avatar style (corner radius, background)themes.xmlCometChatGroupMembersStyle with cometchatGroupMembersAvatarStyle<item name="cometchatAvatarStrokeRadius">8dp</item>
Separator colorthemes.xmlCometChatGroupMembersStyle with cometchatGroupMembersSeparatorColor<item name="cometchatGroupMembersSeparatorColor">#F76808</item>
Title text colorthemes.xmlCometChatGroupMembersStyle with cometchatGroupMembersTitleTextColor<item name="cometchatGroupMembersTitleTextColor">#F76808</item>
Back icon tintthemes.xmlCometChatGroupMembersStyle with cometchatGroupMembersBackIconTint<item name="cometchatGroupMembersBackIconTint">#F76808</item>
Apply a custom styleActivity/FragmentsetStyle(int styleRes)cometchatGroupMembers.setStyle(R.style.CustomGroupMembersStyle);
Set the groupActivity/FragmentsetGroup(Group).setGroup(group);
Back button visibilityActivity/FragmentsetBackIconVisibility(int).setBackIconVisibility(View.VISIBLE);
Toolbar visibilityActivity/FragmentsetToolbarVisibility(int).setToolbarVisibility(View.GONE);
Error state visibilityActivity/FragmentsetErrorStateVisibility(int).setErrorStateVisibility(View.GONE);
Empty state visibilityActivity/FragmentsetEmptyStateVisibility(int).setEmptyStateVisibility(View.GONE);
Loading state visibilityActivity/FragmentsetLoadingStateVisibility(int).setLoadingStateVisibility(View.GONE);
Separator visibilityActivity/FragmentsetSeparatorVisibility(int).setSeparatorVisibility(View.GONE);
User online status visibilityActivity/FragmentsetUsersStatusVisibility(int).setUsersStatusVisibility(View.GONE);
Selection mode (single/multiple)Activity/FragmentsetSelectionMode(SelectionMode).setSelectionMode(UIKitConstants.SelectionMode.MULTIPLE);
Search keywordActivity/FragmentsetSearchkeyword(String).setSearchkeyword("anything");
Search box visibilityActivity/FragmentsetSearchBoxVisibility(int).setSearchBoxVisibility(View.GONE);
Filter group membersActivity/FragmentsetGroupMembersRequestBuilder(GroupMembersRequestBuilder)See Filters code above
Search request builderActivity/FragmentsetSearchRequestBuilder(GroupMembersRequestBuilder)See SearchRequestBuilder code above
Interaction options (replace)Activity/FragmentsetOptions(Function2)See setOptions code above
Interaction options (append)Activity/FragmentaddOptions(Function2)See addOptions code above
Loading viewActivity/FragmentsetLoadingView(int)cometchatUsers.setLoadingView(R.layout.your_loading_view);
Empty viewActivity/FragmentsetEmptyView(int)cometchatUsers.setEmptyView(R.layout.your_empty_view);
Error viewActivity/FragmentsetErrorView(int)cometchatUsers.setErrorView(R.layout.your_empty_view);
Leading view (avatar area)Activity/FragmentsetLeadingView(GroupMembersViewHolderListeners)See setLeadingView code above
Title viewActivity/FragmentsetTitleView(GroupMembersViewHolderListeners)See setTitleView code above
Subtitle viewActivity/FragmentsetSubtitleView(GroupMembersViewHolderListeners)See setSubTitleView code above
Trailing viewActivity/FragmentsetTrailingView(GroupMembersViewHolderListeners)See setTrailingView code above
Entire list itemActivity/FragmentsetItemView(GroupMembersViewHolderListeners)See setItemView code above
Overflow menuActivity/FragmentsetOverflowMenu(View)cometchatGroupMembers.setOverflowMenu(v);

Common pitfalls & fixes

PitfallFix
Component does not renderEnsure CometChatUIKit.init() is called and awaited before using any UI Kit component. If init() has not completed, the component will not load data.
Group member list is empty despite having membersVerify that setGroup(group) is called with a valid Group object that has a correct GUID. The component requires a group to fetch members.
setGroup not calledsetGroup is a required property. If you define CometChatGroupMembers in XML, you must still call setGroup() programmatically in your Activity or Fragment.
Filters not appliedEnsure you call setGroupMembersRequestBuilder(builder) on the CometChatGroupMembers instance after creating and configuring the builder.
Custom style not visibleVerify the style parent is CometChatGroupMembersStyle and that you call setStyle(R.style.YourStyle) on the component instance.
Event listener not receiving eventsEnsure you call CometChatGroupEvents.addGroupListener with a unique LISTENER_ID. If you use the same ID as another listener, the previous one is replaced.
Custom view returns null in createViewIf createView returns null, the default view is used. Return a valid inflated View to replace the default.
Scope badge not showing for participantsIn the trailing view example, the badge is only visible when groupMember.getScope() equals UIKitConstants.GroupMemberScope.PARTICIPANTS. If you want it visible for all scopes, remove the visibility condition.
Search not workingEnsure you call setSearchRequestBuilder with a properly configured GroupMembersRequestBuilder that includes setSearchKeyword.

FAQ

Q: How do I filter group members by scope (admin, moderator, participant)? A: Create a GroupMembersRequest.GroupMembersRequestBuilder, call setScopes(List<String>) with the desired scopes, and pass it to setGroupMembersRequestBuilder. Q: How do I listen for member kick, ban, or scope change events outside the component? A: Use CometChatGroupEvents.addGroupListener("YOUR_TAG", ...) and override ccGroupMemberKicked, ccGroupMemberBanned, or ccGroupMemberScopeChanged. Call CometChatGroupEvents.removeListener("YOUR_TAG") to unsubscribe. Q: Can I show a custom badge for each member’s role? A: Yes. Use setLeadingView or setTitleView with a GroupMembersViewHolderListeners implementation. In bindView, check groupMember.getScope() against UIKitConstants.GroupMemberScope.ADMIN, UIKitConstants.GroupMemberScope.MODERATOR, and UIKitConstants.GroupMemberScope.PARTICIPANTS to set different badge backgrounds. Q: How do I customize the avatar and separator styles? A: Define custom styles with parent CometChatAvatarStyle in themes.xml, reference them in a CometChatGroupMembersStyle using cometchatGroupMembersAvatarStyle, and apply with setStyle(). Q: How do I add custom options without removing the defaults? A: Use addOptions instead of setOptions. addOptions appends your custom MenuItem objects to the existing default options.

Next steps