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

# Users With Messages

> Users With Messages — CometChat documentation.

## Overview

`CometChatUsersWithMessages` is a [Composite Component](/ui-kit/android/v4/components-overview#components) that seamlessly merges the functionalities of both the [Users](/ui-kit/android/v4/users) and [Messages](/ui-kit/android/v4/messages) modules. It empowers users to effortlessly navigate to any individual's chat window by simply clicking on their respective **list item** in the user list.

Additionally, `CometChatUsersWithMessages` inherits and encompasses all attributes available within the `CometChatUsers` module, ensuring a comprehensive user experience.

<Frame>
  <img src="https://mintcdn.com/cometchat-22654f5b/avBd8wan4jblx26s/images/27142b51-users_with_messages_overview_cometchat_screens-3908a4b578c996773adc66e5278a7a3d.png?fit=max&auto=format&n=avBd8wan4jblx26s&q=85&s=4da6651e66b5b9e49b99cef70ea76d15" width="4498" height="3120" data-path="images/27142b51-users_with_messages_overview_cometchat_screens-3908a4b578c996773adc66e5278a7a3d.png" />
</Frame>

| Components                              | Description                                                                                                                                                                                                                                                                                                              |
| --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [Users](/ui-kit/android/v4/users)       | `Users` serves as a standalone component designed to establish a screen displaying a list of `users`, providing them with the capability to search for specific individuals. This component operates as a container, inheriting from `CometChatListBase`, and serves as a wrapper for the `CometChatUserList` component. |
| [Messages](/ui-kit/android/v4/messages) | `Messages` presents the chat interface for both individual `users` and `group` entities. It exhibits a message list containing all interactions where the loggedInUser has sent or received messages from any of these entities.                                                                                         |

## Usage

### Integration

The following code snippet illustrates how you can directly incorporate the Users component into your `layout.xml` file.

<Tabs>
  <Tab title="XML">
    ```xml theme={null}
    <com.cometchat.chatuikit.userswithmessages.CometChatUsersWithMessages
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/users_with_messages"
        />
    ```
  </Tab>
</Tabs>

***

### Actions

[Actions](/ui-kit/android/v4/components-overview#actions) dictate how a component functions. They are divided into two types: Predefined and User-defined. You can override either type, allowing you to tailor the behavior of the component to fit your specific needs.

##### 1. onError

This action doesn't change the behavior of the component but rather listens for any errors that occur in the Conversations component.

<Tabs>
  <Tab title="Java">
    ```java YourActivity.java theme={null}
    usersWithMessages.setOnError(new OnError() {
        @Override
        public void onError(Context context, CometChatException e) {
            //Your Exception Handling code.
        }
    });
    ```
  </Tab>

  <Tab title="Kotlin">
    ```kotlin YourActivity.kt theme={null}
    usersWithMessages.setOnError(object : OnError {
        override fun onError(context: Context, e: CometChatException) {
            // Your Exception Handling code.
        }
    })
    ```
  </Tab>
</Tabs>

### 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.

While the UsersWithMessages component does not have filters, its components do, For more detail on individual filters of its component refer to [Users Filters](/ui-kit/android/v4/users)[Messages Filters](/ui-kit/android/v4/messages#filters)

By utilizing the [Configurations](#configurations) object of its components, you can apply filters.

In the following **example**, we're sorting `Users` by allowing friends and setting the `limit` to 10 using the `usersRequestBuilder`.

<Tabs>
  <Tab title="Java">
    ```java theme={null}
    UsersConfiguration usersConfiguration = new UsersConfiguration();

    UsersRequest.UsersRequestBuilder builder = new UsersRequestUsersRequestBuilder()
            .setLimit(10)
            .friendsOnly(true);
    usersConfiguration.setUsersRequestBuilder(builder);
    usersWithMessages.setUsersConfiguration(usersConfiguration);
    ```
  </Tab>

  <Tab title="Kotlin">
    ```kotlin theme={null}
    val usersConfiguration = UsersConfiguration()

    val builder = UsersRequest.UsersRequestBuilder()
        .setLimit(10)
        .friendsOnly(true)

    usersConfiguration.setUsersRequestBuilder(builder)
    usersWithMessages.setUsersConfiguration(usersConfiguration)
    ```
  </Tab>
</Tabs>

***

### Events

[Events](/ui-kit/android/v4/components-overview#events) are emitted by a `Component`. 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 `UsersWithMessages` does not produce any events but its component does.

***

## Customization

To fit your app's design requirements, you have the ability to customize the appearance of the UsersWithMessages 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.

You can also customize its component styles. For more details on individual component styles, you can refer [Users Styles](/ui-kit/android/v4/users#style) and [Messages Styles](/ui-kit/android/v4/messages#style).

Styles can be applied to SubComponents using their respective configurations.

**Example**

Here we are changing the style of [Users](/ui-kit/android/v4/users) and [Messages](/ui-kit/android/v4/messages) component using [UsersConfiguration](/ui-kit/android/v4/users-with-messages#users) and [MessageConfiguration](/ui-kit/android/v4/users-with-messages#messages)

```java theme={null}
UsersStyle usersStyle = new UsersStyle();
usersStyle.setBackground(Color.GRAY);
usersStyle.setBorderWidth(30);

UsersConfiguration usersConfiguration =new UsersConfiguration();
usersConfiguration.setStyle(usersStyle);

usersWithMessages.setUsersConfiguration(usersConfiguration);

MessagesStyle messagesStyle = new MessagesStyle();
messagesStyle.setBackground(Color.BLACK);

MessagesConfiguration messagesConfiguration =new MessagesConfiguration();
messagesConfiguration.setStyle(messagesStyle);

usersWithMessages.setMessagesConfiguration(messagesConfiguration);
```

### 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.

UsersWithMessages component does not have any available functionality. You can use Functional customisation its [Components](/ui-kit/android/v4/components-overview#components). For more details on individual component functionalities, you can refer [Users Functionalities](/ui-kit/android/v4/users#functionality) and [Messages functionalities](/ui-kit/android/v4/messages#functionality).

***

### 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 own views, layouts, and UI elements and then incorporate those into the component.

UsersWithMessages component does not have any advanced-level customization . You can use Advanced customisation its [Components](/ui-kit/android/v4/components-overview#components). For more details on individual component functionalities, you can refer [Users Advanced](/ui-kit/android/v4/users#advanced) and [Messages Advanced](/ui-kit/android/v4/messages#advanced).

UsersWithMessages uses advanced-level customization of both Users & Messages components to achieve its default behavior.

1. UsersWithMessages utilizes the [Itemclicklistener](/ui-kit/android/v4/users#2-itemclicklistener) function of the `Users` subcomponent to navigate the [User](/ui-kit/android/v4/users) to [Messages](/ui-kit/android/v4/messages)

<Frame>
  <img src="https://mintcdn.com/cometchat-22654f5b/O4T1K2wxFuaRj1dC/images/a3f53852-users_to_messages_cometchat_screens-3703f2ad89c1304b5f1e72435622a189.png?fit=max&auto=format&n=O4T1K2wxFuaRj1dC&q=85&s=4d0b03d6502eea477029200ed0cf8f55" width="4498" height="3120" data-path="images/a3f53852-users_to_messages_cometchat_screens-3703f2ad89c1304b5f1e72435622a189.png" />
</Frame>

2. UsersWithMessages utilizes the [SetMenu](/ui-kit/android/v4/users) function of the `Messages` subcomponent to navigatefrom [Messages](/ui-kit/android/v4/messages) to Details.

<Frame>
  <img src="https://mintcdn.com/cometchat-22654f5b/veBAxaR1km9EBnSg/images/3bedc5b3-messages_to_details_cometchat_screens-eb50d6c7a7d40415e51005ef9428648d.png?fit=max&auto=format&n=veBAxaR1km9EBnSg&q=85&s=1fd45d743729acc585e0665273557eff" width="4498" height="3120" data-path="images/3bedc5b3-messages_to_details_cometchat_screens-eb50d6c7a7d40415e51005ef9428648d.png" />
</Frame>

<Warning>
  When you override `.setMenu()`, the default behavior of **UsersWithMessages** will also be overridden.
</Warning>

## Configurations

[Configurations](/ui-kit/android/v4/components-overview#configurations) offer the ability to customize the properties of each component within a Composite Component.

**UsersWithMessages** has `Users` and `Messages` component. Hence, each of these components will have its individual `Configuration`. `Configurations` expose properties that are available in its individual components.

***

#### Users

You can customize the properties of the Users component by making use of the UsersConfiguration. You can accomplish this by employing the following method as demonstrated below:

<Tabs>
  <Tab title="Java">
    ```java theme={null}
    UsersConfiguration usersConfiguration =new UsersConfiguration();

    usersWithMessages.setUsersConfiguration(usersConfiguration);
    ```
  </Tab>

  <Tab title="Kotlin">
    ```kotlin theme={null}
    val usersConfiguration = UsersConfiguration()
    usersWithMessages.setUsersConfiguration(usersConfiguration)
    ```
  </Tab>
</Tabs>

All exposed properties of `UsersConfiguration` can be found under [Users](/ui-kit/android/v4/users#configuration). Properties marked with the 🛑 symbol are not accessible within the Configuration Object.

**Example**

Let's say you want to change the style of the Users subcomponent

You can modify the style using the `UsersStyle` method.

<Frame>
  <img src="https://mintcdn.com/cometchat-22654f5b/CrArf1QwUPg5EvCC/images/29e1d141-users_with_messages_user_configuration_cometchat_screens-6e5d1957eb9dcfe893c4b0d3f265fc8e.png?fit=max&auto=format&n=CrArf1QwUPg5EvCC&q=85&s=f9d8ed3bf5f7e33c71d5611036b3cb1a" width="4498" height="3120" data-path="images/29e1d141-users_with_messages_user_configuration_cometchat_screens-6e5d1957eb9dcfe893c4b0d3f265fc8e.png" />
</Frame>

<Tabs>
  <Tab title="Java">
    ```java theme={null}
    UsersStyle usersStyle = new UsersStyle();
    usersStyle.setBackground(Color.GRAY);
    UsersConfiguration usersConfiguration =new UsersConfiguration();
    usersConfiguration.setStyle(usersStyle);
    usersWithMessages.setUsersConfiguration(usersConfiguration);
    ```
  </Tab>
</Tabs>

***

#### Messages

You can customize the properties of the Messages component by making use of the `messagesConfiguration`. You can accomplish this by employing the `messagesConfiguration` as demonstrated below:

<Tabs>
  <Tab title="Java">
    ```java theme={null}
    MessagesConfiguration messagesConfiguration =new MessagesConfiguration();
    usersWithMessages.setMessagesConfiguration(messagesConfiguration);
    ```
  </Tab>
</Tabs>

All exposed properties of `MessagesConfiguration` can be found under [Messages](/ui-kit/android/v4/messages#configuration). Properties marked with the 🛑 symbol are not accessible within the Configuration Object.

**Example**

Let's say you want to change the style of the Messages subcomponent and, in addition, you want to hide message composer.

You can modify the style using the `messagesStyle` method and hide using `hide(messageComposer: bool)` method.

<Frame>
  <img src="https://mintcdn.com/cometchat-22654f5b/Relz_yItqW5RHUsU/images/50c05689-users_with_messages_message_configuration_cometchat_screens-0e7e8f93370407ca96d5cb62c027d3ac.png?fit=max&auto=format&n=Relz_yItqW5RHUsU&q=85&s=ede72d9b4386f6c85140f98d25634a4a" width="4498" height="3120" data-path="images/50c05689-users_with_messages_message_configuration_cometchat_screens-0e7e8f93370407ca96d5cb62c027d3ac.png" />
</Frame>

<Tabs>
  <Tab title="Java">
    ```java theme={null}
    MessagesStyle messagesStyle = new MessagesStyle();
     messagesStyle.setBackground(Color.GRAY);
     MessagesConfiguration messagesConfiguration =new MessagesConfiguration();
     messagesConfiguration.setHideMessageComposer(true);
     messagesConfiguration.setStyle(messagesStyle);
    ```
  </Tab>
</Tabs>
