Skip to main content
Components display state views when the list is empty, an error occurs, or data is loading. You can replace these with your own custom views.

State Types

StateWhen it shows
LoadingData is being fetched
EmptyNo data to display
ErrorAn error occurred during data fetching

Replacing State Views

Each component accepts a View? for each state:
// Custom empty view
val emptyView = LayoutInflater.from(context)
    .inflate(R.layout.custom_empty_state, null)
conversations.setEmptyView(emptyView)

// Custom error view
val errorView = LayoutInflater.from(context)
    .inflate(R.layout.custom_error_state, null)
conversations.setErrorView(errorView)

// Custom loading view
val loadingView = LayoutInflater.from(context)
    .inflate(R.layout.custom_loading_state, null)
conversations.setLoadingView(loadingView)
Example custom empty layout:
res/layout/custom_empty_state.xml
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:orientation="vertical"
    android:padding="32dp">

    <ImageView
        android:layout_width="120dp"
        android:layout_height="120dp"
        android:src="@drawable/ic_empty_conversations"
        android:contentDescription="No conversations" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="16dp"
        android:text="No conversations yet"
        android:textSize="18sp" />
</LinearLayout>

Hiding State Views

Components like CometChatMessageList provide explicit hide methods:
messageList.setHideLoadingState(true)
messageList.setHideEmptyState(true)
messageList.setHideErrorState(true)
For components that don’t have dedicated hide methods (e.g., CometChatConversations), pass null to remove a custom state view:
conversations.setEmptyView(null)
conversations.setErrorView(null)
conversations.setLoadingView(null)

Components with State Views

State views are available on all list-based components:
ComponentStates supported
CometChatConversationsLoading, Empty, Error
CometChatUsersLoading, Empty, Error
CometChatGroupsLoading, Empty, Error
CometChatGroupMembersLoading, Empty, Error
CometChatCallLogsLoading, Empty, Error
CometChatMessageListLoading, Empty, Error