> ## Documentation Index
> Fetch the complete documentation index at: https://cometchat-013b37f0.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Conversations With Messages

## Overview

The ConversationsWithMessages is a [Composite Component](/ui-kit/android/v4/components-overview#composite-components) encompassing components such as [Conversations](/ui-kit/android/v4/conversations), [Messages](/ui-kit/android/v4/messages), and [Contacts](/ui-kit/android/v4/contacts). Each of these component contributes to the functionality and structure of the overall ConversationsWithMessages component.

<Frame>
  <img src="https://mintcdn.com/cometchat-013b37f0/crySXmrfj1cbCy1Q/images/2d0d011a-conversationwithmessages_overview_cometchat_screens-bcf3ebae771ecadb04deb7a4f93eb919.png?fit=max&auto=format&n=crySXmrfj1cbCy1Q&q=85&s=8b5ee8730207b7f815ab33f586b47826" width="4498" height="3120" data-path="images/2d0d011a-conversationwithmessages_overview_cometchat_screens-bcf3ebae771ecadb04deb7a4f93eb919.png" />
</Frame>

| Components                                        | Description                                                                                                                                            |
| ------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [Conversations](/ui-kit/android/v4/conversations) | The `Conversations` component is designed to display a list of either `User` or `Group`. This essentially represents your recent conversation history. |
| [Messages](/ui-kit/android/v4/messages)           | The `Messages` component is designed to manage the messaging interaction for either individual `User` or `Group` conversations.                        |
| [Contacts](/ui-kit/android/v4/contacts)           | The `CometChatContacts` component is specifically designed to facilitate the display and management of both `User` and `Groups`.                       |

## Usage

### Integration

There are multiple ways in which you can use ConversationsWithMessages in your app.

**Layout File**: To use ConversationsWithMessages in your \`layout\_activity.xml, use the following code snippet.

```xml layout_activity.xml theme={null}
<com.cometchat.chatuikit.conversationswithmessages.CometChatConversationsWithMessages
        android:id="@+id/conversation"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
```

***

**Activity**: To use ConversationsWithMessages in your \`Activity, use the following code snippet.

<Tabs>
  <Tab title="Java">
    ```java YourActivity.java theme={null}
     @Override
        override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
            return cometChatConversationsWithMessages(context)
        }
    ```
  </Tab>

  <Tab title="Kotlin">
    ```kotlin YourActivity.kt theme={null}
     override fun onCreateView(inflater: LayoutInflater,container: ViewGroup?,savedInstanceState: Bundle?): View {
        return cometChatConversationsWithMessages(requireContext())
    }
    ```
  </Tab>
</Tabs>

***

**Fragment**: To use ConversationsWithMessages in your \`Fragment, use the following code snippet.

<Tabs>
  <Tab title="Java">
    ```java YourFragment.java theme={null}
     @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
           setContentView(new cometChatConversationsWithMessages(this));
        }
    ```
  </Tab>

  <Tab title="Kotlin">
    ```kotlin YourFragment.kt theme={null}
     override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(cometChatConversationsWithMessages(this))
    }
    ```
  </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.

While the ConversationsWithMessages component does not have its actions, its components - [Conversation](/ui-kit/android/v4/conversations#actions), [Messages](/ui-kit/android/v4/messages#actions), and [Contacts](/ui-kit/android/v4/contacts) - each have their own set of actions.

The Action of the components can be overridden through the use of the [Configurations](#configurations) object of its components. Here is an example code snippet.

<Tabs>
  <Tab title="Java">
    ```java theme={null}
     ConversationsConfiguration configuration = new ConversationsConfiguration();
     configuration.setOnError((context, e) -> {
        //Your Error handling action.
    });

    ContactsConfiguration contactsConfiguration = new ContactsConfiguration();
        contactsConfiguration.setOnSubmitIconClick((context, list, list1) -> {
        //Your action on submit click.
    });
    ```
  </Tab>

  <Tab title="Kotlin">
    ```kotlin theme={null}
    val configuration = ConversationsConfiguration()
    configuration.onError = { context, e ->
        // Your error handling action
    }

    val contactsConfiguration = ContactsConfiguration()
    contactsConfiguration.onSubmitIconClick = { context, list, list1 ->
        // Your action on submit click
    }
    ```
  </Tab>
</Tabs>

The ConversationsWithMessages component overrides several actions from its components to reach its default behavior. The list of actions overridden by ConversationsWithMessages includes:

* [ItemClickListener](/ui-kit/android/v4/conversations#1-itemclicklistener) : By overriding the `ItemClickListener` of the Conversation Component, ConversationsWithMessages achieves navigation from [Conversation](/ui-kit/android/v4/conversations) to [Messages](/ui-kit/android/v4/messages) component.

  <Frame>
    <img src="https://mintcdn.com/cometchat-013b37f0/crySXmrfj1cbCy1Q/images/2d0d011a-conversationwithmessages_overview_cometchat_screens-bcf3ebae771ecadb04deb7a4f93eb919.png?fit=max&auto=format&n=crySXmrfj1cbCy1Q&q=85&s=8b5ee8730207b7f815ab33f586b47826" width="4498" height="3120" data-path="images/2d0d011a-conversationwithmessages_overview_cometchat_screens-bcf3ebae771ecadb04deb7a4f93eb919.png" />
  </Frame>

### 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 ConversationsWithMessages component does not have filters, its components do, For more detail on individual filters of its component refer to [Conversations Filters](/ui-kit/android/v4/conversations#filters) and [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 filtering Conversation to only show `User`

<Tabs>
  <Tab title="Java">
    ```java YourActivity.java theme={null}
    ConversationsConfiguration configuration = new ConversationsConfiguration();
    ConversationsRequest.ConversationsRequestBuilder builder = new ConversationsRequest.ConversationsRequestBuilder();
                builder.setConversationType(CometChatConstants.CONVERSATION_TYPE_USER);
                builder.setLimit(50);

    configuration.setConversationsRequestBuilder(builder);
    ```
  </Tab>

  <Tab title="Kotlin">
    ```kotlin theme={null}
    val configuration = ConversationsConfiguration()
    val builder = ConversationsRequest.ConversationsRequestBuilder()
    builder.setConversationType(CometChatConstants.CONVERSATION_TYPE_USER)
    builder.setLimit(50)

    configuration.conversationsRequestBuilder = builder
    ```
  </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 ConversationsWithMessages does not generate its events but its component does. For a full list of these events, you can refer to [Conversations events](/ui-kit/android/v4/conversations#events) and [Messages events](/ui-kit/android/v4/messages#events).

In the following example, we're incorporating observers for the `ConversationDeleted` event of `Conversations` and the `MessageSent` event of the `Messages` component.

<Tabs>
  <Tab title="Java">
    ```java theme={null}
        CometChatConversationEvents.addListener("LISTENER_TAG", new CometChatConversationEvents() {
            @Override
            public void ccConversationDeleted(Conversation conversation) {
                // Your Action
            }
        });

        CometChatMessageEvents.addListener("LISTENER_TAG", new CometChatMessageEvents() {
            @Override
            public void ccMessageSent(BaseMessage baseMessage, int status) {
                // Your Action
            }
        });
    ```
  </Tab>

  <Tab title="Kotlin">
    ```kotlin theme={null}
    CometChatConversationEvents.addListener("LISTENER_TAG", object : CometChatConversationEvents() {
        override fun ccConversationDeleted(conversation: Conversation) {
            // Your Action
        }
    })

    CometChatMessageEvents.addListener("LISTENER_TAG", object : CometChatMessageEvents() {
        override fun ccMessageSent(baseMessage: BaseMessage, status: Int) {
            // Your Action
        }
    })
    ```
  </Tab>
</Tabs>

***

## Customization

To fit your app's design requirements, you have the ability to customize the appearance of the ConversationsWithMessages 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. ConversationsWithMessages component doesn't have its own style parameters. But you can customize its component styles. For more details on individual component styles, you can refer [Conversation Styles](/ui-kit/android/v4/conversations#style), [Messages Styles](/ui-kit/android/v4/messages#style), and [Contacts Styles](/ui-kit/android/v4/contacts#contactsstyle)

Styles can be applied to SubComponents using their respective [configurations](#configurations).

**Example**

<Tabs>
  <Tab title="Java">
    ```java theme={null}
    CometChatConversationsWithMessages conversationsWithMessages = findViewById(R.id.conversation);

    ConversationsStyle conversationsStyle = new ConversationsStyle();
    conversationsStyle.setBackground(Color.parseColor("#757575"));
    conversationsStyle.setSeparatorColor(Color.parseColor("#424242"));
    conversationsStyle.setTitleColor(Color.parseColor("#424242"));

    ConversationsConfiguration configuration = new ConversationsConfiguration();
    configuration.setConversationsRequestBuilder(builder);
    configuration.setStyle(conversationsStyle);

    conversationsWithMessages.setConversationsConfiguration(configuration);
    ```
  </Tab>

  <Tab title="Kotlin">
    ```kotlin theme={null}
    val conversationsWithMessages: CometChatConversationsWithMessages = findViewById(R.id.conversation)

    val conversationsStyle = ConversationsStyle()
    conversationsStyle.setBackground(Color.parseColor("#757575"))
    conversationsStyle.setSeparatorColor(Color.parseColor("#424242"))
    conversationsStyle.setTitleColor(Color.parseColor("#424242"))

    val configuration = ConversationsConfiguration()
    configuration.setConversationsRequestBuilder(builder)
    configuration.setStyle(conversationsStyle)

    conversationsWithMessages.setConversationsConfiguration(configuration)
    ```
  </Tab>
</Tabs>

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

##### Set User

You can utilize the `.setUser(user)` function with a [User](/sdk/android/user-management) object as input to ConversationsWithMessages. This will automatically guide you to the [Messages](/ui-kit/android/v4/messages#functionality) component for the designated `User`.

<Tabs>
  <Tab title="Java">
    ```java theme={null}
    conversationsWithMessages.setUser(user);
    ```
  </Tab>

  <Tab title="kotlin">
    ```
    conversationsWithMessages.user = user
    ```
  </Tab>
</Tabs>

***

##### Set Group

You can utilize the `.setGroup(group)` function with a [Group](/sdk/android/groups-overview) object as input to ConversationsWithMessages. This will automatically guide you to the [Messages](/ui-kit/android/v4/messages) component for the designated `Group`.

<Tabs>
  <Tab title="Java">
    ```java theme={null}
    conversationsWithMessages.setGroup(group);
    ```
  </Tab>

  <Tab title="kotlin">
    ```
    conversationsWithMessages.group = group
    ```
  </Tab>
</Tabs>

***

##### Components

Nearly all functionality customizations available for a Component are also available for the composite component. Using [Configuration](#configurations), you can modify the properties of its components to suit your needs.

You can find the list of all Functionality customization of individual components in [Conversations](/ui-kit/android/v4/conversations#functionality) , [Messages](/ui-kit/android/v4/messages#functionality), and [Contacts](/ui-kit/android/v4/contacts)

**Example**

```java theme={null}
ConversationsConfiguration conversationsConfiguration = new ConversationsConfiguration();
conversationsConfiguration.setTitle("Your Custom Title");
conversationsConfiguration.showBackButton(true);

MessagesConfiguration messagesConfiguration = new MessagesConfiguration();
messagesConfiguration.setDisableTyping(false);
messagesConfiguration.setHideMessageHeader(true);

conversationsWithMessages.setConversationsConfiguration(conversationsConfiguration);
conversationsWithMessages.setMessagesConfiguration(messagesConfiguration);
```

***

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

By utilizing the [Configuration](#configurations) object of each component, you can apply advanced-level customizations to the ConversationsWithMessages.

**Example**

```java theme={null}
ConversationsConfiguration conversationsConfiguration = new ConversationsConfiguration();
conversationsConfiguration.setErrorStateView(R.layout.your_custom_view);

conversationsWithMessages.setConversationsConfiguration(conversationsConfiguration);
```

To find all the details on individual Component advance customization you can refer, [Conversations Advance](/ui-kit/android/v4/conversations#advanced),[Messages Advance](/ui-kit/android/v4/messages#advanced) and [Contacts Advance](/ui-kit/android/v4/contacts)

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

1. ConversationsWithMessages utilizes the [SetMenu](/ui-kit/android/v4/conversations#setmenu) function of the `Conversations` subcomponent to navigate the user from [Conversations](/ui-kit/android/v4/conversations) to [Contacts](/ui-kit/android/v4/contacts)

   <Frame>
     <img src="https://mintcdn.com/cometchat-013b37f0/Ljt9AcZicJcNxpPO/images/0d2524b3-conversationwithmessages_to_contacts_cometchat_screens-ffe1b2deab523d2db18b8a7a3b4f6fc3.png?fit=max&auto=format&n=Ljt9AcZicJcNxpPO&q=85&s=03dfa7f690f7f10ef9982f2a26faee20" width="4498" height="3120" data-path="images/0d2524b3-conversationwithmessages_to_contacts_cometchat_screens-ffe1b2deab523d2db18b8a7a3b4f6fc3.png" />
   </Frame>

2. ConversationsWithMessages utilizes the [SetMenu](/ui-kit/android/v4/message-header#setmenu) function of the `Messages` subcomponent to navigate the user from [Messages](/ui-kit/android/v4/messages) to [Details](/ui-kit/android/v4/group-details).

   <Frame>
     <img src="https://mintcdn.com/cometchat-013b37f0/Y1jO_gcbgesM4HIm/images/2ed6b63c-conversationwithmessages_to_details_cometchat_screens-ecc00f1f7939382b5921a4e6338b785e.png?fit=max&auto=format&n=Y1jO_gcbgesM4HIm&q=85&s=74213ccd0af7ca964fe1d601bb357f06" width="4498" height="3120" data-path="images/2ed6b63c-conversationwithmessages_to_details_cometchat_screens-ecc00f1f7939382b5921a4e6338b785e.png" />
   </Frame>

<Warning>
  When you override `.setMenu()`, the default behavior of ConversationsWithMessages 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.

ConversationsWithMessages has `Conversations`, `Messages`, and `Contacts` component. Hence, each of these components will have its individual \`Configuration\`\`.

* `Configurations` expose properties that are available in its individual components.

#### Conversations

You can customize the properties of the Conversations component by making use of the ConversationsConfiguration. You can accomplish this by employing the `.setConversationsConfiguration()` method as demonstrated below:

<Tabs>
  <Tab title="Java">
    ```java theme={null}
    ConversationsConfiguration configuration = new ConversationsConfiguration();
    conversationsWithMessages.setConversationsConfiguration(configuration);
    ```
  </Tab>

  <Tab title="Kotlin">
    ```kotlin theme={null}
    val configuration = ConversationsConfiguration()
    conversationsWithMessages.setConversationsConfiguration(configuration)
    ```
  </Tab>
</Tabs>

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

**Example**

Let's say you want to change the style of the Conversations subcomponent and, in addition, you only want to display users in the conversation list.

You can modify the style using the `.setStyle()` method and filter the list with the `.setConversationsRequestBuilder()` method.

<Frame>
  <img src="https://mintcdn.com/cometchat-013b37f0/-u9ODPUkMM-sHNen/images/466c97fd-conversationwithmessages_conversation_configuration_cometchat_screens-f9d2b02ee42068853ec1944d9fc5a26c.png?fit=max&auto=format&n=-u9ODPUkMM-sHNen&q=85&s=0d1cbc64bf098bd3c0f8e381c016eedb" width="4498" height="3120" data-path="images/466c97fd-conversationwithmessages_conversation_configuration_cometchat_screens-f9d2b02ee42068853ec1944d9fc5a26c.png" />
</Frame>

<Tabs>
  <Tab title="Java">
    ```java theme={null}
    CometChatConversationsWithMessages conversationsWithMessages = findViewById(R.id.conversation);

    ConversationsRequest.ConversationsRequestBuilder builder = new ConversationsRequest.ConversationsRequestBuilder();
    builder.setConversationType(CometChatConstants.CONVERSATION_TYPE_USER);

    ConversationsStyle conversationsStyle = new ConversationsStyle();
    conversationsStyle.setBackground(Color.parseColor("#757575"));
    conversationsStyle.setSeparatorColor(Color.parseColor("#424242"));
    conversationsStyle.setTitleColor(Color.parseColor("#424242"));

    ListItemStyle listItemStyle = new ListItemStyle();
    listItemStyle.setTitleColor(Color.parseColor("#424242"));

    ConversationsConfiguration configuration = new ConversationsConfiguration();
    configuration.setConversationsRequestBuilder(builder);
    configuration.setStyle(conversationsStyle);
    configuration.setListItemStyle(listItemStyle);

    conversationsWithMessages.setConversationsConfiguration(configuration);
    ```
  </Tab>

  <Tab title="Kotlin">
    ```kotlin theme={null}
    val conversationsWithMessages = findViewById<CometChatConversationsWithMessages>(R.id.conversation)

    val builder = ConversationsRequest.ConversationsRequestBuilder()
    builder.setConversationType(CometChatConstants.CONVERSATION_TYPE_USER)

    val conversationsStyle = ConversationsStyle()
    conversationsStyle.setBackground(Color.parseColor("#757575"))
    conversationsStyle.setSeparatorColor(Color.parseColor("#424242"))
    conversationsStyle.setTitleColor(Color.parseColor("#424242"))

    val listItemStyle = ListItemStyle()
    listItemStyle.setTitleColor(Color.parseColor("#424242"))

    val configuration = ConversationsConfiguration()
    configuration.setConversationsRequestBuilder(builder)
    configuration.setStyle(conversationsStyle)
    configuration.setListItemStyle(listItemStyle)

    conversationsWithMessages.setConversationsConfiguration(configuration)
    ```
  </Tab>
</Tabs>

***

#### Messages

***

#### Contacts

***
