Component-Level Callbacks
Click Callbacks
| Setter | Triggered When |
|---|---|
setOnItemClick(OnItemClick<Conversation>) | User taps a list item |
setOnItemLongClick(OnItemLongClick<Conversation>) | User long-presses a list item |
setOnBackPressListener(OnBackPress) | User taps the back button |
setOnSearchClickListener(OnSearchClick) | User taps the search icon |
- Kotlin
- Java
Error Callback
UsesetOnError to handle component-level errors:
- Kotlin
- Java
Selection Mode
Enable single or multi-select on list components:| Method | Description |
|---|---|
setSelectionMode(UIKitConstants.SelectionMode) | Set the selection mode: NONE, SINGLE, or MULTIPLE |
setOnSelect(OnSelection<Conversation>) | Callback when selection changes |
getSelectedConversations() | Get the list of currently selected conversations |
clearSelection() | Clear all selections |
selectConversation(Conversation, SelectionMode) | Programmatically select a conversation |
- Kotlin
- Java
Global Events
Global events are fired by the UI Kit when actions happen anywhere in the app. Register listeners using the static listener registration methods on each event class (addListener, addGroupListener, or addUserListener depending on the class).
| Event Class | Fires When |
|---|---|
CometChatConversationEvents | Conversation is deleted or updated |
CometChatMessageEvents | Messages are sent, edited, deleted, or reacted to |
CometChatGroupEvents | Groups are created, updated, members added/removed |
CometChatUserEvents | Users are blocked/unblocked |
CometChatUIEvents | UI-level events like opening chat, showing dialogs |
CometChatCallEvents | Calls are initiated, accepted, rejected, or ended |
String tag so it can be removed later.
Component-Level vs Global Events
- Component-level callbacks (e.g.,
setOnItemClick) are set on a specific View instance and only fire for that component. - Global events (e.g.,
CometChatMessageEvents.addListener) are static and fire regardless of which component triggered the action. Use them for cross-component coordination.
- Kotlin
- Java
Related
- Events Reference — Full list of all event classes and their methods.
- Customization Overview — See all customization categories.