# Message Bubble

## Text Message Bubble

![](/files/-MX75laujLrEXWxjsSaI)

## Image Massage Bubble

<figure><img src="/files/zYauW9zU4SXMrCAtK2Ko" alt=""><figcaption></figcaption></figure>

## Audio Message Bubble

<figure><img src="/files/BAa2CEpfwuQQbg2Dqa67" alt=""><figcaption></figcaption></figure>

## Usage

To customize message bubble, implement **AmityMessageListAdapter.CustomViewHolder** and pass a custom `ViewHolder` for  the corresponding message type.

```
class MainActivity : AppCompatActivity(), AmityMessageListAdapter.CustomViewHolder {
```

```

   override fun onCreate(savedInstanceState: Bundle?) {
       super.onCreate(savedInstanceState)
       setContentView(R.layout.activity_main)
       
        /**
         * Implement [AmityMessageListAdapter.CustomViewHolder] if customization is required for messageViews
         * set the customView listener using [AmityChatRoomFragment] instance
         */
       val chatRoomFragment = AmityChatRoomFragment
                                .newInstance("channelId")
                                .enableChatToolbar(boolean)
                                .customViewHolder(this)
                                .build(this)
        
        val transaction = supportFragmentManager.beginTransaction()
        transaction.replace(R.id.fragmentContainer, messageListFragment)
        transaction.addToBackStack(null)
        transaction.commit()
   }
}
```

Override method `getViewHolder()` to pass a custom `ViewHolder`

```
override fun getViewHolder(
        inflater: LayoutInflater,
        parent: ViewGroup,
        viewType: Int
    ): AmityChatMessageBaseViewHolder? {
        return when(viewType) {
            MessageType.MESSAGE_ID_TEXT_RECEIVER -> TextReceiverViewHolder(
                inflater.inflate(R.layout.custom_item_text_receiver, parent, false), EkoChatMessageBaseViewModel())
            MessageType.MESSAGE_ID_TEXT_SENDER -> TextSenderViewHolder(
                inflater.inflate(R.layout.custom_item_text_sender, parent, false), EkoChatMessageBaseViewModel()
            )
            //pass null for all the types where no customisation is required
            //Default UIKIT Ui will be rendered for all those types
            else -> null
        }
    }
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.social.plus/social-plus-uikit/uikit-3/android/chat-uikit/using-your-own-component/message-bubble.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
