> ## Documentation Index
> Fetch the complete documentation index at: https://cometchat-22654f5b-docs-rn-guide-message-privately.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Adapters

> Access or replace the RecyclerView Adapter to control how list items are rendered and manage list data directly.

List-based components like `CometChatConversations` use a `RecyclerView.Adapter` to bind data to list items. You can access the default adapter to manipulate data, or replace it entirely with a custom implementation.

## Accessing the Adapter

<Tabs>
  <Tab title="Kotlin">
    ```kotlin theme={null}
    val conversations = CometChatConversations(context)
    val adapter: ConversationsAdapter = conversations.getConversationsAdapter()
    ```
  </Tab>

  <Tab title="Java">
    ```java theme={null}
    CometChatConversations conversations = new CometChatConversations(context);
    ConversationsAdapter adapter = conversations.getConversationsAdapter();
    ```
  </Tab>
</Tabs>

## Replacing the Adapter

Use `setAdapter` to replace the default adapter with a custom implementation:

<Tabs>
  <Tab title="Kotlin">
    ```kotlin theme={null}
    val customAdapter = ConversationsAdapter(context)
    // Configure your custom adapter...
    conversations.setAdapter(customAdapter)
    ```
  </Tab>

  <Tab title="Java">
    ```java theme={null}
    ConversationsAdapter customAdapter = new ConversationsAdapter(context);
    // Configure your custom adapter...
    conversations.setAdapter(customAdapter);
    ```
  </Tab>
</Tabs>

## Data Manipulation API

The adapter provides methods to programmatically manage the list data:

| Method                             | Description                                  |
| ---------------------------------- | -------------------------------------------- |
| `setList(List<Conversation>)`      | Replace the entire list                      |
| `addList(List<Conversation>)`      | Append conversations to the end              |
| `add(Conversation)`                | Add a single conversation to the end         |
| `add(int position, Conversation)`  | Insert a conversation at a specific position |
| `remove(int position)`             | Remove a conversation by position            |
| `remove(Conversation)`             | Remove a specific conversation               |
| `clear()`                          | Remove all conversations                     |
| `updateConversation(Conversation)` | Update an existing conversation in place     |
| `getConversationsList()`           | Get the current list of conversations        |

<Tabs>
  <Tab title="Kotlin">
    ```kotlin theme={null}
    val adapter = conversations.getConversationsAdapter()

    // Get the current list
    val currentList = adapter.getConversationsList()

    // Add a conversation at the top
    adapter.add(0, newConversation)

    // Remove a conversation
    adapter.remove(conversation)

    // Replace the entire list
    adapter.setList(filteredConversations)
    ```
  </Tab>

  <Tab title="Java">
    ```java theme={null}
    ConversationsAdapter adapter = conversations.getConversationsAdapter();

    // Get the current list
    List<Conversation> currentList = adapter.getConversationsList();

    // Add a conversation at the top
    adapter.add(0, newConversation);

    // Remove a conversation
    adapter.remove(conversation);

    // Replace the entire list
    adapter.setList(filteredConversations);
    ```
  </Tab>
</Tabs>

## View Slots on the Adapter

The adapter exposes the same view slot setters as the View layer. When you set a view slot on the View (e.g., `conversations.setSubtitleView(...)`), it delegates to the adapter internally. You can also set view slots directly on the adapter:

| Adapter Method                 | Equivalent View Method               |
| ------------------------------ | ------------------------------------ |
| `adapter.setLeadingView(...)`  | `conversations.setLeadingView(...)`  |
| `adapter.setTitleView(...)`    | `conversations.setTitleView(...)`    |
| `adapter.setSubtitleView(...)` | `conversations.setSubtitleView(...)` |
| `adapter.setTrailingView(...)` | `conversations.setTrailingView(...)` |
| `adapter.setItemView(...)`     | `conversations.setItemView(...)`     |

Setting view slots directly on the adapter is useful when you've replaced the adapter with `setAdapter` and need to configure it before attaching.

## Adapter Style Propagation

The adapter has its own style setter methods. These are typically called internally by the View layer, but you can use them directly when working with a custom adapter:

| Method                                                | Applies To                            |
| ----------------------------------------------------- | ------------------------------------- |
| `setConversationsAvatarStyle(@StyleRes int)`          | Avatar style for list items           |
| `setConversationsBadgeStyle(@StyleRes int)`           | Unread badge style                    |
| `setConversationsReceiptStyle(@StyleRes int)`         | Message receipt icon style            |
| `setConversationsDateStyle(@StyleRes int)`            | Date/time label style                 |
| `setConversationsTypingIndicatorStyle(@StyleRes int)` | Typing indicator style                |
| `setConversationsStatusIndicatorStyle(@StyleRes int)` | Online/offline status indicator style |

## Related

* [View Slots](/ui-kit/android/customization-view-slots) — Learn the ViewHolderListener pattern used by adapter view slots.
* [ViewModel & Data](/ui-kit/android/customization-viewmodel-data) — Manage data at the ViewModel level instead of the adapter.
* [Customization Overview](/ui-kit/android/customization-overview) — See all customization categories.
